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.
Attributes collapse
-
#clustering_fields=(fields) ⇒ Object
Sets one or more fields on which data should be clustered.
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.
-
#numeric(name, description: nil, mode: :nullable) ⇒ Object
Adds a numeric number 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, #clustering?, #clustering_fields, #copy, #copy_job, #created_at, #data, #dataset_id, #delete, #description, #description=, #encryption, #encryption=, #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_field, #time_partitioning_field=, #time_partitioning_type, #time_partitioning_type=, #view?
Constructor Details
#initialize(gapi) ⇒ Updater
Create an Updater object.
2511 2512 2513 2514 2515 |
# File 'lib/google/cloud/bigquery/table.rb', line 2511 def initialize gapi @updates = [] @gapi = gapi @schema = nil end |
Instance Attribute Details
#updates ⇒ Object (readonly)
A list of attributes that were updated.
2507 2508 2509 |
# File 'lib/google/cloud/bigquery/table.rb', line 2507 def updates @updates end |
Instance Method Details
#boolean(name, description: nil, mode: :nullable) ⇒ Object
Adds a boolean field to the schema.
See Schema#boolean.
2770 2771 2772 |
# File 'lib/google/cloud/bigquery/table.rb', line 2770 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.
2798 2799 2800 |
# File 'lib/google/cloud/bigquery/table.rb', line 2798 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
2954 2955 2956 2957 2958 2959 |
# File 'lib/google/cloud/bigquery/table.rb', line 2954 def check_for_mutated_schema! return if @schema.nil? return unless @schema.changed? @gapi.schema = @schema.to_gapi patch_gapi! :schema end |
#clustering_fields=(fields) ⇒ Object
Sets one or more fields on which data should be clustered. Must be specified with time-based partitioning, data in the table will be first partitioned and subsequently clustered.
Only top-level, non-repeated, simple-type fields are supported. When you cluster a table using multiple columns, the order of columns you specify is important. The order of the specified columns determines the sort order of the data.
You can only set the clustering fields while creating a table as in the example below. BigQuery does not allow you to change clustering on an existing table.
2561 2562 2563 2564 2565 |
# File 'lib/google/cloud/bigquery/table.rb', line 2561 def clustering_fields= fields @gapi.clustering ||= Google::Apis::BigqueryV2::Clustering.new @gapi.clustering.fields = fields patch_gapi! :clustering end |
#date(name, description: nil, mode: :nullable) ⇒ Object
Adds a date field to the schema.
See Schema#date.
2910 2911 2912 |
# File 'lib/google/cloud/bigquery/table.rb', line 2910 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.
2882 2883 2884 |
# File 'lib/google/cloud/bigquery/table.rb', line 2882 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.
2712 2713 2714 |
# File 'lib/google/cloud/bigquery/table.rb', line 2712 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.
2684 2685 2686 |
# File 'lib/google/cloud/bigquery/table.rb', line 2684 def integer name, description: nil, mode: :nullable schema.integer name, description: description, mode: mode end |
#numeric(name, description: nil, mode: :nullable) ⇒ Object
Adds a numeric number field to the schema. Numeric is a fixed-precision numeric type with 38 decimal digits, 9 that follow the decimal point.
See Schema#numeric
2742 2743 2744 |
# File 'lib/google/cloud/bigquery/table.rb', line 2742 def numeric name, description: nil, mode: :nullable schema.numeric 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.
2948 2949 2950 |
# File 'lib/google/cloud/bigquery/table.rb', line 2948 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.
2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 |
# File 'lib/google/cloud/bigquery/table.rb', line 2619 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.
2656 2657 2658 |
# File 'lib/google/cloud/bigquery/table.rb', line 2656 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.
2854 2855 2856 |
# File 'lib/google/cloud/bigquery/table.rb', line 2854 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.
2826 2827 2828 |
# File 'lib/google/cloud/bigquery/table.rb', line 2826 def name, description: nil, mode: :nullable schema. name, description: description, mode: mode end |
#to_gapi ⇒ Object
2961 2962 2963 2964 |
# File 'lib/google/cloud/bigquery/table.rb', line 2961 def to_gapi check_for_mutated_schema! @gapi end |