Class: Gcloud::Bigquery::Table::Updater
- Inherits:
-
Gcloud::Bigquery::Table
- Object
- Gcloud::Bigquery::Table
- Gcloud::Bigquery::Table::Updater
- Defined in:
- lib/gcloud/bigquery/table.rb
Overview
Yielded to a block to accumulate changes for a patch request.
Lifecycle collapse
-
#updates ⇒ Object
readonly
A list of attributes that were updated.
Attributes inherited from Gcloud::Bigquery::Table
Lifecycle collapse
-
#initialize(gapi) ⇒ Updater
constructor
Create an Updater object.
Schema collapse
-
#boolean(name, description: nil, mode: :nullable) ⇒ Object
Adds a boolean field to the schema.
-
#check_for_mutated_schema! ⇒ Object
Make sure any access changes are saved.
-
#float(name, description: nil, mode: :nullable) ⇒ Object
Adds a floating-point number field to the schema.
-
#integer(name, description: nil, mode: :nullable) ⇒ Object
Adds an integer field to the schema.
-
#record(name, description: nil, mode: nil) {|nested_schema| ... } ⇒ Object
Adds a record field to the schema.
-
#schema(replace: false) {|schema| ... } ⇒ Gcloud::Bigquery::Schema
Returns the table’s schema.
-
#string(name, description: nil, mode: :nullable) ⇒ Object
Adds a string field to the schema.
-
#timestamp(name, description: nil, mode: :nullable) ⇒ Object
Adds a timestamp field to the schema.
- #to_gapi ⇒ Object
Methods inherited from Gcloud::Bigquery::Table
#api_url, #bytes_count, #copy, #created_at, #data, #dataset_id, #delete, #description, #description=, #etag, #expires_at, #extract, #fields, from_gapi, #headers, #id, #insert, #load, #location, #modified_at, #name, #name=, #project_id, #query_id, #reload!, #rows_count, #table?, #table_id, #table_ref, #view?
Constructor Details
#initialize(gapi) ⇒ Updater
Create an Updater object.
868 869 870 871 872 |
# File 'lib/gcloud/bigquery/table.rb', line 868 def initialize gapi @updates = [] @gapi = gapi @schema = nil end |
Instance Attribute Details
#updates ⇒ Object (readonly)
A list of attributes that were updated.
864 865 866 |
# File 'lib/gcloud/bigquery/table.rb', line 864 def updates @updates end |
Instance Method Details
#boolean(name, description: nil, mode: :nullable) ⇒ Object
Adds a boolean field to the schema.
See Schema#boolean.
1037 1038 1039 |
# File 'lib/gcloud/bigquery/table.rb', line 1037 def boolean name, description: nil, mode: :nullable schema.boolean name, description: description, mode: mode end |
#check_for_mutated_schema! ⇒ Object
Make sure any access changes are saved
1111 1112 1113 1114 1115 1116 1117 |
# File 'lib/gcloud/bigquery/table.rb', line 1111 def check_for_mutated_schema! return if @schema.nil? @schema.check_for_mutated_schema! return unless @schema.changed? @gapi.schema = @schema.to_gapi patch_gapi! :schema end |
#float(name, description: nil, mode: :nullable) ⇒ Object
Adds a floating-point number field to the schema.
See Schema#float.
1008 1009 1010 |
# File 'lib/gcloud/bigquery/table.rb', line 1008 def float name, description: nil, mode: :nullable schema.float name, description: description, mode: mode end |
#integer(name, description: nil, mode: :nullable) ⇒ Object
Adds an integer field to the schema.
See Schema#integer.
979 980 981 |
# File 'lib/gcloud/bigquery/table.rb', line 979 def integer name, description: nil, mode: :nullable schema.integer name, description: description, mode: mode end |
#record(name, description: nil, mode: nil) {|nested_schema| ... } ⇒ Object
Adds a record field to the schema. A block must be passed describing the nested fields of the record. For more information about nested and repeated records, see [Preparing Data for BigQuery ](cloud.google.com/bigquery/preparing-data-for-bigquery).
See Schema#record.
1105 1106 1107 |
# File 'lib/gcloud/bigquery/table.rb', line 1105 def record name, description: nil, mode: nil, &block schema.record name, description: description, mode: mode, &block end |
#schema(replace: false) {|schema| ... } ⇒ Gcloud::Bigquery::Schema
Returns the table’s schema. This method can also be used to set, replace, or add to the schema by passing a block. See Schema for available methods.
909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 |
# File 'lib/gcloud/bigquery/table.rb', line 909 def schema replace: false # Same as Table#schema, but not frozen # TODO: make sure to call ensure_full_data! on Dataset#update @schema ||= Schema.from_gapi @gapi.schema if block_given? if replace @schema = Schema.from_gapi \ Google::Apis::BigqueryV2::TableSchema.new(fields: []) end yield @schema check_for_mutated_schema! end # Do not freeze on updater, allow modifications @schema end |
#string(name, description: nil, mode: :nullable) ⇒ Object
Adds a string field to the schema.
See Schema#string.
950 951 952 |
# File 'lib/gcloud/bigquery/table.rb', line 950 def string name, description: nil, mode: :nullable schema.string name, description: description, mode: mode end |
#timestamp(name, description: nil, mode: :nullable) ⇒ Object
Adds a timestamp field to the schema.
See Schema#timestamp.
1066 1067 1068 |
# File 'lib/gcloud/bigquery/table.rb', line 1066 def name, description: nil, mode: :nullable schema. name, description: description, mode: mode end |
#to_gapi ⇒ Object
1119 1120 1121 1122 |
# File 'lib/gcloud/bigquery/table.rb', line 1119 def to_gapi check_for_mutated_schema! @gapi end |