Class: Google::Cloud::Bigquery::QueryJob::Updater
- Inherits:
-
Google::Cloud::Bigquery::QueryJob
- Object
- Job
- Google::Cloud::Bigquery::QueryJob
- Google::Cloud::Bigquery::QueryJob::Updater
- Defined in:
- lib/google/cloud/bigquery/query_job.rb
Overview
Yielded to a block to accumulate changes for a patch request.
Attributes collapse
-
#cache=(value) ⇒ Object
Specifies to look in the query cache for results.
- #cancel ⇒ Object
-
#clustering_fields=(fields) ⇒ Object
Sets the list of fields on which data should be clustered.
-
#create=(value) ⇒ Object
Sets the create disposition for creating the query results table.
-
#create_session=(value) ⇒ Object
Sets the create_session property.
-
#dataset=(value) ⇒ Object
Sets the default dataset of tables referenced in the query.
-
#dryrun=(value) ⇒ Object
(also: #dry_run=)
Sets the dry run flag for the query job.
-
#encryption=(val) ⇒ Object
Sets the encryption configuration of the destination table.
-
#external=(value) ⇒ Object
Sets definitions for external tables used in the query.
-
#flatten=(value) ⇒ Object
Flatten nested and repeated fields in legacy SQL queries.
-
#labels=(value) ⇒ Object
Sets the labels to use for the job.
-
#large_results=(value) ⇒ Object
Allow large results for a legacy SQL query.
-
#legacy_sql=(value) ⇒ Object
Sets the query syntax to legacy SQL.
-
#location=(value) ⇒ Object
Sets the geographic location where the job should run.
-
#maximum_bytes_billed=(value) ⇒ Object
Sets the maximum bytes billed for the query.
-
#params=(params) ⇒ Object
Sets the query parameters.
-
#priority=(value) ⇒ Object
Sets the priority of the query.
-
#range_partitioning_end=(range_end) ⇒ Object
Sets the end of range partitioning, exclusive, for the destination table.
-
#range_partitioning_field=(field) ⇒ Object
Sets the field on which to range partition the table.
-
#range_partitioning_interval=(range_interval) ⇒ Object
Sets width of each interval for data in range partitions.
-
#range_partitioning_start=(range_start) ⇒ Object
Sets the start of range partitioning, inclusive, for the destination table.
- #reload! ⇒ Object (also: #refresh!)
- #rerun! ⇒ Object
-
#reservation=(value) ⇒ Object
Sets the reservation that job would use.
-
#session_id=(value) ⇒ Object
Sets the session ID for a query run in session mode.
-
#set_params_and_types(params, types = nil) ⇒ Object
Sets the query parameters.
-
#standard_sql=(value) ⇒ Object
Sets the query syntax to standard SQL.
-
#table=(value) ⇒ Object
Sets the destination for the query results table.
-
#time_partitioning_expiration=(expiration) ⇒ Object
Sets the partition expiration for the destination table.
-
#time_partitioning_field=(field) ⇒ Object
Sets the field on which to partition the destination table.
-
#time_partitioning_require_filter=(val) ⇒ Object
If set to true, queries over the destination table will require a partition filter that can be used for partition elimination to be specified.
-
#time_partitioning_type=(type) ⇒ Object
Sets the partitioning for the destination table.
-
#udfs=(value) ⇒ Object
Sets user defined functions for the query.
- #wait_until_done! ⇒ Object
-
#write=(value) ⇒ Object
Sets the write disposition for when the query results table exists.
Methods inherited from Google::Cloud::Bigquery::QueryJob
#batch?, #bytes_processed, #cache?, #cache_hit?, #clustering?, #clustering_fields, #data, #ddl?, #ddl_operation_performed, #ddl_target_routine, #ddl_target_table, #deleted_row_count, #destination, #dml?, #dryrun?, #encryption, #flatten?, #inserted_row_count, #interactive?, #large_results?, #legacy_sql?, #maximum_billing_tier, #maximum_bytes_billed, #num_dml_affected_rows, #query_plan, #range_partitioning?, #range_partitioning_end, #range_partitioning_field, #range_partitioning_interval, #range_partitioning_start, #standard_sql?, #statement_type, #time_partitioning?, #time_partitioning_expiration, #time_partitioning_field, #time_partitioning_require_filter?, #time_partitioning_type, #udfs, #updated_row_count
Methods inherited from Job
#configuration, #created_at, #delete, #done?, #ended_at, #error, #errors, #failed?, #job_id, #labels, #location, #num_child_jobs, #parent_job_id, #pending?, #project_id, #reservation_usage, #running?, #script_statistics, #session_id, #started_at, #state, #statistics, #status, #transaction_id, #user_email
Instance Method Details
#cache=(value) ⇒ Object
Specifies to look in the query cache for results.
869 870 871 |
# File 'lib/google/cloud/bigquery/query_job.rb', line 869 def cache= value @gapi.configuration.query.use_query_cache = value end |
#cancel ⇒ Object
1612 1613 1614 |
# File 'lib/google/cloud/bigquery/query_job.rb', line 1612 def cancel raise "not implemented in #{self.class}" end |
#clustering_fields=(fields) ⇒ Object
Sets the list of fields on which data should be 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.
BigQuery supports clustering for both partitioned and non-partitioned tables.
See Google::Cloud::Bigquery::QueryJob#clustering_fields, Table#clustering_fields and Table#clustering_fields=.
1595 1596 1597 1598 |
# File 'lib/google/cloud/bigquery/query_job.rb', line 1595 def clustering_fields= fields @gapi.configuration.query.clustering ||= Google::Apis::BigqueryV2::Clustering.new @gapi.configuration.query.clustering.fields = fields end |
#create=(value) ⇒ Object
Sets the create disposition for creating the query results table.
create new tables. The default value is needed.
The following values are supported:
needed- Create the table if it does not exist.never- The table must already exist. A 'notFound' error is raised if the table does not exist.
1047 1048 1049 |
# File 'lib/google/cloud/bigquery/query_job.rb', line 1047 def create= value @gapi.configuration.query.create_disposition = Convert.create_disposition value end |
#create_session=(value) ⇒ Object
Sets the create_session property. If true, creates a new session,
where session id will be a server generated random id. If false,
runs query with an existing #session_id=, otherwise runs query in
non-session mode. The default value is false.
value is false.
1061 1062 1063 |
# File 'lib/google/cloud/bigquery/query_job.rb', line 1061 def create_session= value @gapi.configuration.query.create_session = value end |
#dataset=(value) ⇒ Object
Sets the default dataset of tables referenced in the query.
906 907 908 |
# File 'lib/google/cloud/bigquery/query_job.rb', line 906 def dataset= value @gapi.configuration.query.default_dataset = @service.dataset_ref_from value end |
#dryrun=(value) ⇒ Object Also known as: dry_run=
Sets the dry run flag for the query job.
1109 1110 1111 |
# File 'lib/google/cloud/bigquery/query_job.rb', line 1109 def dryrun= value @gapi.configuration.dry_run = value end |
#encryption=(val) ⇒ Object
Sets the encryption configuration of the destination table.
1249 1250 1251 |
# File 'lib/google/cloud/bigquery/query_job.rb', line 1249 def encryption= val @gapi.configuration.query.update! destination_encryption_configuration: val.to_gapi end |
#external=(value) ⇒ Object
Sets definitions for external tables used in the query.
1207 1208 1209 1210 1211 |
# File 'lib/google/cloud/bigquery/query_job.rb', line 1207 def external= value external_table_pairs = value.map { |name, obj| [String(name), obj.to_gapi] } external_table_hash = external_table_pairs.to_h @gapi.configuration.query.table_definitions = external_table_hash end |
#flatten=(value) ⇒ Object
Flatten nested and repeated fields in legacy SQL queries.
895 896 897 |
# File 'lib/google/cloud/bigquery/query_job.rb', line 895 def flatten= value @gapi.configuration.query.flatten_results = value end |
#labels=(value) ⇒ Object
Sets the labels to use for the job.
1161 1162 1163 |
# File 'lib/google/cloud/bigquery/query_job.rb', line 1161 def labels= value @gapi.configuration.update! labels: value end |
#large_results=(value) ⇒ Object
Allow large results for a legacy SQL query.
882 883 884 |
# File 'lib/google/cloud/bigquery/query_job.rb', line 882 def large_results= value @gapi.configuration.query.allow_large_results = value end |
#legacy_sql=(value) ⇒ Object
Sets the query syntax to legacy SQL.
1177 1178 1179 |
# File 'lib/google/cloud/bigquery/query_job.rb', line 1177 def legacy_sql= value @gapi.configuration.query.use_legacy_sql = value end |
#location=(value) ⇒ Object
Sets the geographic location where the job should run. Required except for US and EU.
839 840 841 842 843 844 845 846 |
# File 'lib/google/cloud/bigquery/query_job.rb', line 839 def location= value @gapi.job_reference.location = value return unless value.nil? # Treat assigning value of nil the same as unsetting the value. unset = @gapi.job_reference.instance_variables.include? :@location @gapi.job_reference.remove_instance_variable :@location if unset end |
#maximum_bytes_billed=(value) ⇒ Object
Sets the maximum bytes billed for the query.
1135 1136 1137 |
# File 'lib/google/cloud/bigquery/query_job.rb', line 1135 def maximum_bytes_billed= value @gapi.configuration.query.maximum_bytes_billed = value end |
#params=(params) ⇒ Object
Sets the query parameters. Standard SQL only.
Use #set_params_and_types to set both params and types.
946 947 948 |
# File 'lib/google/cloud/bigquery/query_job.rb', line 946 def params= params set_params_and_types params end |
#priority=(value) ⇒ Object
Sets the priority of the query.
855 856 857 |
# File 'lib/google/cloud/bigquery/query_job.rb', line 855 def priority= value @gapi.configuration.query.priority = priority_value value end |
#range_partitioning_end=(range_end) ⇒ Object
Sets the end of range partitioning, exclusive, for the destination table. See Creating and using integer range partitioned tables.
You can only set range partitioning when creating a table. BigQuery does not allow you to change partitioning on an existing table.
See #range_partitioning_start=, #range_partitioning_interval= and #range_partitioning_field=.
1404 1405 1406 1407 1408 1409 |
# File 'lib/google/cloud/bigquery/query_job.rb', line 1404 def range_partitioning_end= range_end @gapi.configuration.query.range_partitioning ||= Google::Apis::BigqueryV2::RangePartitioning.new( range: Google::Apis::BigqueryV2::RangePartitioning::Range.new ) @gapi.configuration.query.range_partitioning.range.end = range_end end |
#range_partitioning_field=(field) ⇒ Object
Sets the field on which to range partition the table. See Creating and using integer range partitioned tables.
See #range_partitioning_start=, #range_partitioning_interval= and #range_partitioning_end=.
You can only set range partitioning when creating a table. BigQuery does not allow you to change partitioning on an existing table.
1287 1288 1289 1290 1291 1292 |
# File 'lib/google/cloud/bigquery/query_job.rb', line 1287 def range_partitioning_field= field @gapi.configuration.query.range_partitioning ||= Google::Apis::BigqueryV2::RangePartitioning.new( range: Google::Apis::BigqueryV2::RangePartitioning::Range.new ) @gapi.configuration.query.range_partitioning.field = field end |
#range_partitioning_interval=(range_interval) ⇒ Object
Sets width of each interval for data in range partitions. See Creating and using integer range partitioned tables.
You can only set range partitioning when creating a table. BigQuery does not allow you to change partitioning on an existing table.
See #range_partitioning_field=, #range_partitioning_start= and #range_partitioning_end=.
1365 1366 1367 1368 1369 1370 |
# File 'lib/google/cloud/bigquery/query_job.rb', line 1365 def range_partitioning_interval= range_interval @gapi.configuration.query.range_partitioning ||= Google::Apis::BigqueryV2::RangePartitioning.new( range: Google::Apis::BigqueryV2::RangePartitioning::Range.new ) @gapi.configuration.query.range_partitioning.range.interval = range_interval end |
#range_partitioning_start=(range_start) ⇒ Object
Sets the start of range partitioning, inclusive, for the destination table. See Creating and using integer range partitioned tables.
You can only set range partitioning when creating a table. BigQuery does not allow you to change partitioning on an existing table.
See #range_partitioning_field=, #range_partitioning_interval= and #range_partitioning_end=.
1326 1327 1328 1329 1330 1331 |
# File 'lib/google/cloud/bigquery/query_job.rb', line 1326 def range_partitioning_start= range_start @gapi.configuration.query.range_partitioning ||= Google::Apis::BigqueryV2::RangePartitioning.new( range: Google::Apis::BigqueryV2::RangePartitioning::Range.new ) @gapi.configuration.query.range_partitioning.range.start = range_start end |
#reload! ⇒ Object Also known as: refresh!
1620 1621 1622 |
# File 'lib/google/cloud/bigquery/query_job.rb', line 1620 def reload! raise "not implemented in #{self.class}" end |
#rerun! ⇒ Object
1616 1617 1618 |
# File 'lib/google/cloud/bigquery/query_job.rb', line 1616 def rerun! raise "not implemented in #{self.class}" end |
#reservation=(value) ⇒ Object
Sets the reservation that job would use. User can specify a reservation
to execute the job. If reservation is not set, reservation is determined
based on the rules defined by the reservation assignments. The expected
format is projects/project/locations/location/reservations/reservation``.
1608 1609 1610 |
# File 'lib/google/cloud/bigquery/query_job.rb', line 1608 def reservation= value @gapi.configuration.update! reservation: value end |
#session_id=(value) ⇒ Object
Sets the session ID for a query run in session mode. See #create_session=.
1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 |
# File 'lib/google/cloud/bigquery/query_job.rb', line 1071 def session_id= value @gapi.configuration.query.connection_properties ||= [] prop = @gapi.configuration.query.connection_properties.find { |cp| cp.key == "session_id" } if prop prop.value = value else prop = Google::Apis::BigqueryV2::ConnectionProperty.new key: "session_id", value: value @gapi.configuration.query.connection_properties << prop end end |
#set_params_and_types(params, types = nil) ⇒ Object
Sets the query parameters. Standard SQL only.
1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 |
# File 'lib/google/cloud/bigquery/query_job.rb', line 1011 def set_params_and_types params, types = nil types ||= params.class.new raise ArgumentError, "types must use the same format as params" if types.class != params.class case params when Array @gapi.configuration.query.use_legacy_sql = false @gapi.configuration.query.parameter_mode = "POSITIONAL" @gapi.configuration.query.query_parameters = params.zip(types).map do |param, type| Convert.to_query_param param, type end when Hash @gapi.configuration.query.use_legacy_sql = false @gapi.configuration.query.parameter_mode = "NAMED" @gapi.configuration.query.query_parameters = params.map do |name, param| type = types[name] Convert.to_query_param(param, type).tap { |named_param| named_param.name = String name } end else raise ArgumentError, "params must be an Array or a Hash" end end |
#standard_sql=(value) ⇒ Object
Sets the query syntax to standard SQL.
1193 1194 1195 |
# File 'lib/google/cloud/bigquery/query_job.rb', line 1193 def standard_sql= value @gapi.configuration.query.use_legacy_sql = !value end |
#table=(value) ⇒ Object
Sets the destination for the query results table.
1122 1123 1124 |
# File 'lib/google/cloud/bigquery/query_job.rb', line 1122 def table= value @gapi.configuration.query.destination_table = table_ref_from value end |
#time_partitioning_expiration=(expiration) ⇒ Object
Sets the partition expiration for the destination table. See Partitioned Tables.
The destination table must also be partitioned. See #time_partitioning_type=.
1532 1533 1534 1535 |
# File 'lib/google/cloud/bigquery/query_job.rb', line 1532 def time_partitioning_expiration= expiration @gapi.configuration.query.time_partitioning ||= Google::Apis::BigqueryV2::TimePartitioning.new @gapi.configuration.query.time_partitioning.update! expiration_ms: expiration * 1000 end |
#time_partitioning_field=(field) ⇒ Object
Sets the field on which to partition the destination table. If not
set, the destination table is partitioned by pseudo column
_PARTITIONTIME; if set, the table is partitioned by this field.
See Partitioned
Tables.
The destination table must also be partitioned. See #time_partitioning_type=.
You can only set the partitioning field while creating a table. BigQuery does not allow you to change partitioning on an existing table.
1493 1494 1495 1496 |
# File 'lib/google/cloud/bigquery/query_job.rb', line 1493 def time_partitioning_field= field @gapi.configuration.query.time_partitioning ||= Google::Apis::BigqueryV2::TimePartitioning.new @gapi.configuration.query.time_partitioning.update! field: field end |
#time_partitioning_require_filter=(val) ⇒ Object
If set to true, queries over the destination table will require a partition filter that can be used for partition elimination to be specified. See Partitioned Tables.
1548 1549 1550 1551 |
# File 'lib/google/cloud/bigquery/query_job.rb', line 1548 def time_partitioning_require_filter= val @gapi.configuration.query.time_partitioning ||= Google::Apis::BigqueryV2::TimePartitioning.new @gapi.configuration.query.time_partitioning.update! require_partition_filter: val end |
#time_partitioning_type=(type) ⇒ Object
Sets the partitioning for the destination table. See Partitioned
Tables.
The supported types are DAY, HOUR, MONTH, and YEAR, which will
generate one partition per day, hour, month, and year, respectively.
You can only set the partitioning field while creating a table. BigQuery does not allow you to change partitioning on an existing table.
1447 1448 1449 1450 |
# File 'lib/google/cloud/bigquery/query_job.rb', line 1447 def time_partitioning_type= type @gapi.configuration.query.time_partitioning ||= Google::Apis::BigqueryV2::TimePartitioning.new @gapi.configuration.query.time_partitioning.update! type: type end |
#udfs=(value) ⇒ Object
Sets user defined functions for the query.
1225 1226 1227 |
# File 'lib/google/cloud/bigquery/query_job.rb', line 1225 def udfs= value @gapi.configuration.query.user_defined_function_resources = udfs_gapi_from value end |
#wait_until_done! ⇒ Object
1625 1626 1627 |
# File 'lib/google/cloud/bigquery/query_job.rb', line 1625 def wait_until_done! raise "not implemented in #{self.class}" end |
#write=(value) ⇒ Object
Sets the write disposition for when the query results table exists.
1096 1097 1098 |
# File 'lib/google/cloud/bigquery/query_job.rb', line 1096 def write= value @gapi.configuration.query.write_disposition = Convert.write_disposition value end |