Class: Google::Cloud::Bigquery::Table::Updater
- Inherits:
-
Google::Cloud::Bigquery::Table
- Object
- Google::Cloud::Bigquery::Table
- Google::Cloud::Bigquery::Table::Updater
- Defined in:
- lib/google/cloud/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.
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.
-
#bytes(name, description: nil, mode: :nullable) ⇒ Object
Adds a bytes field to the schema.
-
#check_for_mutated_schema! ⇒ Object
Make sure any access changes are saved.
-
#date(name, description: nil, mode: :nullable) ⇒ Object
Adds a date field to the schema.
-
#datetime(name, description: nil, mode: :nullable) ⇒ Object
Adds a datetime field to the schema.
-
#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| ... } ⇒ Google::Cloud::Bigquery::Schema
Returns the table's schema.
-
#string(name, description: nil, mode: :nullable) ⇒ Object
Adds a string field to the schema.
-
#time(name, description: nil, mode: :nullable) ⇒ Object
Adds a time field to the schema.
-
#timestamp(name, description: nil, mode: :nullable) ⇒ Object
Adds a timestamp field to the schema.
- #to_gapi ⇒ Object
Methods inherited from Google::Cloud::Bigquery::Table
#api_url, #buffer_bytes, #buffer_oldest_at, #buffer_rows, #bytes_count, #copy, #copy_job, #created_at, #data, #dataset_id, #delete, #description, #description=, #etag, #exists?, #expires_at, #external, #external=, #external?, #extract, #extract_job, #fields, #headers, #id, #insert, #insert_async, #labels, #labels=, #load, #load_job, #location, #modified_at, #name, #name=, #project_id, #query, #query=, #query_id, #query_legacy_sql?, #query_standard_sql?, #query_udfs, #reference?, #reload!, #resource?, #resource_full?, #resource_partial?, #rows_count, #set_query, #table?, #table_id, #time_partitioning?, #time_partitioning_expiration, #time_partitioning_expiration=, #time_partitioning_type, #time_partitioning_type=, #view?
Constructor Details
#initialize(gapi) ⇒ Updater
Create an Updater object.
2071 2072 2073 2074 2075 |
# File 'lib/google/cloud/bigquery/table.rb', line 2071 def initialize gapi @updates = [] @gapi = gapi @schema = nil end |
Instance Attribute Details
#updates ⇒ Object (readonly)
A list of attributes that were updated.
2067 2068 2069 |
# File 'lib/google/cloud/bigquery/table.rb', line 2067 def updates @updates end |
Instance Method Details
#boolean(name, description: nil, mode: :nullable) ⇒ Object
Adds a boolean field to the schema.
See Schema#boolean.
2232 2233 2234 |
# File 'lib/google/cloud/bigquery/table.rb', line 2232 def boolean name, description: nil, mode: :nullable schema.boolean name, description: description, mode: mode end |
#bytes(name, description: nil, mode: :nullable) ⇒ Object
Adds a bytes field to the schema.
See Schema#bytes.
2260 2261 2262 |
# File 'lib/google/cloud/bigquery/table.rb', line 2260 def bytes name, description: nil, mode: :nullable schema.bytes name, description: description, mode: mode end |
#check_for_mutated_schema! ⇒ Object
Make sure any access changes are saved
2416 2417 2418 2419 2420 2421 |
# File 'lib/google/cloud/bigquery/table.rb', line 2416 def check_for_mutated_schema! return if @schema.nil? return unless @schema.changed? @gapi.schema = @schema.to_gapi patch_gapi! :schema end |
#date(name, description: nil, mode: :nullable) ⇒ Object
Adds a date field to the schema.
See Schema#date.
2372 2373 2374 |
# File 'lib/google/cloud/bigquery/table.rb', line 2372 def date name, description: nil, mode: :nullable schema.date name, description: description, mode: mode end |
#datetime(name, description: nil, mode: :nullable) ⇒ Object
Adds a datetime field to the schema.
See Schema#datetime.
2344 2345 2346 |
# File 'lib/google/cloud/bigquery/table.rb', line 2344 def datetime name, description: nil, mode: :nullable schema.datetime name, description: description, mode: mode end |
#float(name, description: nil, mode: :nullable) ⇒ Object
Adds a floating-point number field to the schema.
See Schema#float.
2204 2205 2206 |
# File 'lib/google/cloud/bigquery/table.rb', line 2204 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.
2176 2177 2178 |
# File 'lib/google/cloud/bigquery/table.rb', line 2176 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 .
See Schema#record.
2410 2411 2412 |
# File 'lib/google/cloud/bigquery/table.rb', line 2410 def record name, description: nil, mode: nil, &block schema.record name, description: description, mode: mode, &block end |
#schema(replace: false) {|schema| ... } ⇒ Google::Cloud::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.
2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 |
# File 'lib/google/cloud/bigquery/table.rb', line 2111 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? @schema = Schema.from_gapi if replace 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.
2148 2149 2150 |
# File 'lib/google/cloud/bigquery/table.rb', line 2148 def string name, description: nil, mode: :nullable schema.string name, description: description, mode: mode end |
#time(name, description: nil, mode: :nullable) ⇒ Object
Adds a time field to the schema.
See Schema#time.
2316 2317 2318 |
# File 'lib/google/cloud/bigquery/table.rb', line 2316 def time name, description: nil, mode: :nullable schema.time name, description: description, mode: mode end |
#timestamp(name, description: nil, mode: :nullable) ⇒ Object
Adds a timestamp field to the schema.
See Schema#timestamp.
2288 2289 2290 |
# File 'lib/google/cloud/bigquery/table.rb', line 2288 def name, description: nil, mode: :nullable schema. name, description: description, mode: mode end |
#to_gapi ⇒ Object
2423 2424 2425 2426 |
# File 'lib/google/cloud/bigquery/table.rb', line 2423 def to_gapi check_for_mutated_schema! @gapi end |