google-cloud-bigquery 1.59.0 → 1.61.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -178,6 +178,12 @@ module Google
178
178
  # * The key portion of a label must be unique. However, you can use the
179
179
  # same key with multiple resources.
180
180
  # * Keys must start with a lowercase letter or international character.
181
+ # @param [String] reservation The reservation that job would use. User
182
+ # can specify a reservation to execute the job. If reservation is not
183
+ # set, reservation is determined based on the rules defined by the
184
+ # reservation assignments. The expected format is
185
+ # `projects/`project`/locations/`location`/reservations/`reservation``.
186
+ #
181
187
  # @yield [job] a job configuration object
182
188
  # @yieldparam [Google::Cloud::Bigquery::CopyJob::Updater] job a job
183
189
  # configuration object for setting additional options.
@@ -199,9 +205,11 @@ module Google
199
205
  #
200
206
  # @!group Data
201
207
  #
202
- def copy_job source_table, destination_table, create: nil, write: nil, job_id: nil, prefix: nil, labels: nil
208
+ def copy_job source_table, destination_table, create: nil, write: nil, job_id: nil, prefix: nil, labels: nil,
209
+ reservation: nil
203
210
  ensure_service!
204
- options = { create: create, write: write, labels: labels, job_id: job_id, prefix: prefix }
211
+ options = { create: create, write: write, labels: labels, job_id: job_id, prefix: prefix,
212
+ reservation: reservation }
205
213
 
206
214
  updater = CopyJob::Updater.from_options(
207
215
  service,
@@ -258,6 +266,12 @@ module Google
258
266
  # * `append` - BigQuery appends the data to the table.
259
267
  # * `empty` - An error will be returned if the destination table
260
268
  # already contains data.
269
+ # @param [String] reservation The reservation that job would use. User
270
+ # can specify a reservation to execute the job. If reservation is not
271
+ # set, reservation is determined based on the rules defined by the
272
+ # reservation assignments. The expected format is
273
+ # `projects/`project`/locations/`location`/reservations/`reservation``.
274
+ #
261
275
  # @yield [job] a job configuration object
262
276
  # @yieldparam [Google::Cloud::Bigquery::CopyJob::Updater] job a job
263
277
  # configuration object for setting additional options.
@@ -276,8 +290,8 @@ module Google
276
290
  #
277
291
  # @!group Data
278
292
  #
279
- def copy source_table, destination_table, create: nil, write: nil, &block
280
- job = copy_job source_table, destination_table, create: create, write: write, &block
293
+ def copy source_table, destination_table, create: nil, write: nil, reservation: nil, &block
294
+ job = copy_job source_table, destination_table, create: create, write: write, reservation: reservation, &block
281
295
  job.wait_until_done!
282
296
  ensure_job_succeeded! job
283
297
  true
@@ -479,6 +493,12 @@ module Google
479
493
  # The default value is false.
480
494
  # @param [String] session_id The ID of an existing session. See also the
481
495
  # `create_session` param and {Job#session_id}.
496
+ # @param [String] reservation The reservation that job would use. User
497
+ # can specify a reservation to execute the job. If reservation is not
498
+ # set, reservation is determined based on the rules defined by the
499
+ # reservation assignments. The expected format is
500
+ # `projects/`project`/locations/`location`/reservations/`reservation``.
501
+ #
482
502
  # @yield [job] a job configuration object
483
503
  # @yieldparam [Google::Cloud::Bigquery::QueryJob::Updater] job a job
484
504
  # configuration object for setting query options.
@@ -631,7 +651,8 @@ module Google
631
651
  labels: nil,
632
652
  udfs: nil,
633
653
  create_session: nil,
634
- session_id: nil
654
+ session_id: nil,
655
+ reservation: nil
635
656
  ensure_service!
636
657
  project ||= self.project
637
658
  options = {
@@ -657,7 +678,8 @@ module Google
657
678
  labels: labels,
658
679
  udfs: udfs,
659
680
  create_session: create_session,
660
- session_id: session_id
681
+ session_id: session_id,
682
+ reservation: reservation
661
683
  }
662
684
 
663
685
  updater = QueryJob::Updater.from_options service, query, options
@@ -785,6 +807,11 @@ module Google
785
807
  # `create_session` param in {#query_job} and {Job#session_id}.
786
808
  # @param [Boolean] format_options_use_int64_timestamp Output timestamp
787
809
  # as usec int64. Default is true.
810
+ # @param [String] reservation The reservation that job would use. User
811
+ # can specify a reservation to execute the job. If reservation is not
812
+ # set, reservation is determined based on the rules defined by the
813
+ # reservation assignments. The expected format is
814
+ # `projects/`project`/locations/`location`/reservations/`reservation``.
788
815
  #
789
816
  # @yield [job] a job configuration object
790
817
  # @yieldparam [Google::Cloud::Bigquery::QueryJob::Updater] job a job
@@ -933,6 +960,7 @@ module Google
933
960
  legacy_sql: nil,
934
961
  session_id: nil,
935
962
  format_options_use_int64_timestamp: true,
963
+ reservation: nil,
936
964
  &block
937
965
  job = query_job query,
938
966
  params: params,
@@ -944,6 +972,7 @@ module Google
944
972
  standard_sql: standard_sql,
945
973
  legacy_sql: legacy_sql,
946
974
  session_id: session_id,
975
+ reservation: reservation,
947
976
  &block
948
977
  job.wait_until_done!
949
978
 
@@ -1152,6 +1181,20 @@ module Google
1152
1181
  # and reorders columns to match the field names in the schema.
1153
1182
  # @param [String] time_zone The time zone used when parsing timestamp
1154
1183
  # values.
1184
+ # @param [String] reference_file_schema_uri The URI of the reference
1185
+ # file with the reader schema. This file is only loaded if it is part
1186
+ # of source URIs, but is not loaded otherwise. It is enabled for the
1187
+ # following formats: `AVRO`, `PARQUET`, `ORC`.
1188
+ # @param [Boolean] preserve_ascii_control_characters When source_format
1189
+ # is set to `CSV`, indicates if the embedded ASCII control characters
1190
+ # (the first 32 characters in the ASCII-table, from `\x00` to `\x1F`)
1191
+ # are preserved. By default, ASCII control characters are not
1192
+ # preserved.
1193
+ # @param [String] reservation The reservation that job would use. User
1194
+ # can specify a reservation to execute the job. If reservation is not
1195
+ # set, reservation is determined based on the rules defined by the
1196
+ # reservation assignments. The expected format is
1197
+ # `projects/`project`/locations/`location`/reservations/`reservation``.
1155
1198
  #
1156
1199
  # @yield [updater] A block for setting the schema and other
1157
1200
  # options for the destination table. The schema can be omitted if the
@@ -1178,7 +1221,8 @@ module Google
1178
1221
  skip_leading: nil, schema: nil, job_id: nil, prefix: nil, labels: nil, autodetect: nil,
1179
1222
  null_marker: nil, dryrun: nil, create_session: nil, session_id: nil, project_id: nil,
1180
1223
  date_format: nil, datetime_format: nil, time_format: nil, timestamp_format: nil,
1181
- null_markers: nil, source_column_match: nil, time_zone: nil, &block
1224
+ null_markers: nil, source_column_match: nil, time_zone: nil, reference_file_schema_uri: nil,
1225
+ preserve_ascii_control_characters: nil, reservation: nil, &block
1182
1226
  ensure_service!
1183
1227
  dataset_id ||= "_SESSION" unless create_session.nil? && session_id.nil?
1184
1228
  session_dataset = dataset dataset_id, skip_lookup: true, project_id: project_id
@@ -1193,7 +1237,9 @@ module Google
1193
1237
  session_id: session_id, date_format: date_format, datetime_format: datetime_format,
1194
1238
  time_format: time_format, timestamp_format: timestamp_format,
1195
1239
  null_markers: null_markers, source_column_match: source_column_match,
1196
- time_zone: time_zone, &block
1240
+ time_zone: time_zone, reference_file_schema_uri: reference_file_schema_uri,
1241
+ preserve_ascii_control_characters: preserve_ascii_control_characters,
1242
+ reservation: reservation, &block
1197
1243
  end
1198
1244
 
1199
1245
  ##
@@ -1348,6 +1394,20 @@ module Google
1348
1394
  # and reorders columns to match the field names in the schema.
1349
1395
  # @param [String] time_zone The time zone used when parsing timestamp
1350
1396
  # values.
1397
+ # @param [String] reference_file_schema_uri The URI of the reference
1398
+ # file with the reader schema. This file is only loaded if it is part
1399
+ # of source URIs, but is not loaded otherwise. It is enabled for the
1400
+ # following formats: `AVRO`, `PARQUET`, `ORC`.
1401
+ # @param [Boolean] preserve_ascii_control_characters When source_format
1402
+ # is set to `CSV`, indicates if the embedded ASCII control characters
1403
+ # (the first 32 characters in the ASCII-table, from `\x00` to `\x1F`)
1404
+ # are preserved. By default, ASCII control characters are not
1405
+ # preserved.
1406
+ # @param [String] reservation The reservation that job would use. User
1407
+ # can specify a reservation to execute the job. If reservation is not
1408
+ # set, reservation is determined based on the rules defined by the
1409
+ # reservation assignments. The expected format is
1410
+ # `projects/`project`/locations/`location`/reservations/`reservation``.
1351
1411
  #
1352
1412
  # @yield [updater] A block for setting the schema of the destination
1353
1413
  # table and other options for the load job. The schema can be omitted
@@ -1379,7 +1439,8 @@ module Google
1379
1439
  delimiter: nil, ignore_unknown: nil, max_bad_records: nil, quote: nil,
1380
1440
  skip_leading: nil, schema: nil, autodetect: nil, null_marker: nil, session_id: nil,
1381
1441
  date_format: nil, datetime_format: nil, time_format: nil, timestamp_format: nil,
1382
- null_markers: nil, source_column_match: nil, time_zone: nil, &block
1442
+ null_markers: nil, source_column_match: nil, time_zone: nil, reference_file_schema_uri: nil,
1443
+ preserve_ascii_control_characters: nil, reservation: nil, &block
1383
1444
  job = load_job table_id, files, dataset_id: dataset_id,
1384
1445
  format: format, create: create, write: write, projection_fields: projection_fields,
1385
1446
  jagged_rows: jagged_rows, quoted_newlines: quoted_newlines, encoding: encoding,
@@ -1388,7 +1449,10 @@ module Google
1388
1449
  null_marker: null_marker, session_id: session_id, date_format: date_format,
1389
1450
  datetime_format: datetime_format, time_format: time_format,
1390
1451
  timestamp_format: timestamp_format, null_markers: null_markers,
1391
- source_column_match: source_column_match, time_zone: time_zone, &block
1452
+ source_column_match: source_column_match, time_zone: time_zone,
1453
+ reference_file_schema_uri: reference_file_schema_uri,
1454
+ preserve_ascii_control_characters: preserve_ascii_control_characters, reservation: reservation,
1455
+ &block
1392
1456
 
1393
1457
  job.wait_until_done!
1394
1458
  ensure_job_succeeded! job
@@ -1472,6 +1536,13 @@ module Google
1472
1536
  # mapped to
1473
1537
  # [IAM Policy version](https://cloud.google.com/iam/docs/policies#versions)
1474
1538
  # and will be used to set policy in IAM.
1539
+ # @param [String] dataset_view The dataset_view parameter is an optional
1540
+ # field in the GetDatasetRequest used to specify which information
1541
+ # about a BigQuery dataset should be returned in the response. By
1542
+ # controlling this parameter, users can request a partial or full
1543
+ # response, which helps enforce fine-grained access control based on
1544
+ # their permissions. {Google::Cloud::Bigquery::DatasetView} provides
1545
+ # constants for this parameter.
1475
1546
  #
1476
1547
  # @return [Google::Cloud::Bigquery::Dataset, nil] Returns `nil` if the
1477
1548
  # dataset does not exist.
@@ -1499,12 +1570,13 @@ module Google
1499
1570
  #
1500
1571
  # dataset = bigquery.dataset "my_dataset", skip_lookup: true
1501
1572
  #
1502
- def dataset dataset_id, skip_lookup: nil, project_id: nil, access_policy_version: nil
1573
+ def dataset dataset_id, skip_lookup: nil, project_id: nil, access_policy_version: nil, dataset_view: nil
1503
1574
  ensure_service!
1504
1575
  project_id ||= project
1505
1576
  return Dataset.new_reference project_id, dataset_id, service if skip_lookup
1506
- gapi = service.get_project_dataset project_id, dataset_id, access_policy_version: access_policy_version
1507
- Dataset.from_gapi gapi, service, access_policy_version: access_policy_version
1577
+ gapi = service.get_project_dataset project_id, dataset_id, access_policy_version: access_policy_version,
1578
+ dataset_view: dataset_view
1579
+ Dataset.from_gapi gapi, service, access_policy_version: access_policy_version, dataset_view: dataset_view
1508
1580
  rescue Google::Cloud::NotFoundError
1509
1581
  nil
1510
1582
  end
@@ -1537,6 +1609,14 @@ module Google
1537
1609
  # mapped to
1538
1610
  # [IAM Policy version](https://cloud.google.com/iam/docs/policies#versions)
1539
1611
  # and will be used to set policy in IAM.
1612
+ # @param [String] dataset_view The dataset_view parameter is an optional
1613
+ # field in the GetDatasetRequest used to specify which information
1614
+ # about a BigQuery dataset should be returned in the response. By
1615
+ # controlling this parameter, users can request a partial or full
1616
+ # response, which helps enforce fine-grained access control based on
1617
+ # their permissions. {Google::Cloud::Bigquery::DatasetView} provides
1618
+ # constants for this parameter.
1619
+ #
1540
1620
  # @yield [access] a block for setting rules
1541
1621
  # @yieldparam [Google::Cloud::Bigquery::Dataset] access the object
1542
1622
  # accepting rules
@@ -1569,7 +1649,8 @@ module Google
1569
1649
  # end
1570
1650
  #
1571
1651
  def create_dataset dataset_id, name: nil, description: nil,
1572
- expiration: nil, location: nil, access_policy_version: nil
1652
+ expiration: nil, location: nil, access_policy_version: nil,
1653
+ dataset_view: nil
1573
1654
  ensure_service!
1574
1655
 
1575
1656
  new_ds = Google::Apis::BigqueryV2::Dataset.new(
@@ -1593,7 +1674,7 @@ module Google
1593
1674
  end
1594
1675
 
1595
1676
  gapi = service.insert_dataset new_ds, access_policy_version: access_policy_version
1596
- Dataset.from_gapi gapi, service, access_policy_version: access_policy_version
1677
+ Dataset.from_gapi gapi, service, access_policy_version: access_policy_version, dataset_view: dataset_view
1597
1678
  end
1598
1679
 
1599
1680
  ##
@@ -2091,6 +2172,12 @@ module Google
2091
2172
  # * The key portion of a label must be unique. However, you can use the
2092
2173
  # same key with multiple resources.
2093
2174
  # * Keys must start with a lowercase letter or international character.
2175
+ # @param [String] reservation The reservation that job would use. User
2176
+ # can specify a reservation to execute the job. If reservation is not
2177
+ # set, reservation is determined based on the rules defined by the
2178
+ # reservation assignments. The expected format is
2179
+ # `projects/`project`/locations/`location`/reservations/`reservation``.
2180
+ #
2094
2181
  # @yield [job] a job configuration object
2095
2182
  # @yieldparam [Google::Cloud::Bigquery::ExtractJob::Updater] job a job
2096
2183
  # configuration object for setting additional options.
@@ -2119,10 +2206,10 @@ module Google
2119
2206
  # @!group Data
2120
2207
  #
2121
2208
  def extract_job source, extract_url, format: nil, compression: nil, delimiter: nil, header: nil, job_id: nil,
2122
- prefix: nil, labels: nil
2209
+ prefix: nil, labels: nil, reservation: nil
2123
2210
  ensure_service!
2124
2211
  options = { format: format, compression: compression, delimiter: delimiter, header: header, job_id: job_id,
2125
- prefix: prefix, labels: labels }
2212
+ prefix: prefix, labels: labels, reservation: reservation }
2126
2213
  source_ref = if source.respond_to? :model_ref
2127
2214
  source.model_ref
2128
2215
  else
@@ -2189,6 +2276,12 @@ module Google
2189
2276
  # models.
2190
2277
  # @param [Boolean] header Whether to print out a header row in table
2191
2278
  # exports. Default is `true`. Not applicable when extracting models.
2279
+ # @param [String] reservation The reservation that job would use. User
2280
+ # can specify a reservation to execute the job. If reservation is not
2281
+ # set, reservation is determined based on the rules defined by the
2282
+ # reservation assignments. The expected format is
2283
+ # `projects/`project`/locations/`location`/reservations/`reservation``.
2284
+ #
2192
2285
  # @yield [job] a job configuration object
2193
2286
  # @yieldparam [Google::Cloud::Bigquery::ExtractJob::Updater] job a job
2194
2287
  # configuration object for setting additional options.
@@ -2214,12 +2307,14 @@ module Google
2214
2307
  #
2215
2308
  # @!group Data
2216
2309
  #
2217
- def extract source, extract_url, format: nil, compression: nil, delimiter: nil, header: nil, &block
2310
+ def extract source, extract_url, format: nil, compression: nil, delimiter: nil, header: nil, reservation: nil,
2311
+ &block
2218
2312
  job = extract_job source, extract_url,
2219
2313
  format: format,
2220
2314
  compression: compression,
2221
2315
  delimiter: delimiter,
2222
2316
  header: header,
2317
+ reservation: reservation,
2223
2318
  &block
2224
2319
  job.wait_until_done!
2225
2320
  ensure_job_succeeded! job
@@ -792,7 +792,8 @@ module Google
792
792
  query: query,
793
793
  default_dataset: dataset_config,
794
794
  maximum_billing_tier: options[:maximum_billing_tier]
795
- )
795
+ ),
796
+ reservation: options[:reservation]
796
797
  )
797
798
  )
798
799
 
@@ -1596,6 +1597,18 @@ module Google
1596
1597
  @gapi.configuration.query.clustering.fields = fields
1597
1598
  end
1598
1599
 
1600
+ ##
1601
+ # Sets the reservation that job would use. User can specify a reservation
1602
+ # to execute the job. If reservation is not set, reservation is determined
1603
+ # based on the rules defined by the reservation assignments. The expected
1604
+ # format is `projects/`project`/locations/`location`/reservations/`reservation``.
1605
+ # @param [String] value The reservation name.
1606
+ #
1607
+ # @!group Attributes
1608
+ def reservation= value
1609
+ @gapi.configuration.update! reservation: value
1610
+ end
1611
+
1599
1612
  def cancel
1600
1613
  raise "not implemented in #{self.class}"
1601
1614
  end
@@ -109,16 +109,18 @@ module Google
109
109
 
110
110
  ##
111
111
  # Returns the dataset specified by datasetID.
112
- def get_dataset dataset_id, access_policy_version: nil
113
- get_project_dataset @project, dataset_id, access_policy_version: access_policy_version
112
+ def get_dataset dataset_id, access_policy_version: nil, dataset_view: nil
113
+ get_project_dataset @project, dataset_id, access_policy_version: access_policy_version,
114
+ dataset_view: dataset_view
114
115
  end
115
116
 
116
117
  ##
117
118
  # Gets the specified dataset resource by full dataset reference.
118
- def get_project_dataset project_id, dataset_id, access_policy_version: nil
119
+ def get_project_dataset project_id, dataset_id, access_policy_version: nil, dataset_view: nil
119
120
  # The get operation is considered idempotent
120
121
  execute backoff: true do
121
- service.get_dataset project_id, dataset_id, access_policy_version: access_policy_version
122
+ service.get_dataset project_id, dataset_id, access_policy_version: access_policy_version,
123
+ dataset_view: dataset_view
122
124
  end
123
125
  end
124
126
 
@@ -131,7 +133,7 @@ module Google
131
133
  ##
132
134
  # Updates information in an existing dataset, only replacing
133
135
  # fields that are provided in the submitted dataset resource.
134
- def patch_dataset dataset_id, patched_dataset_gapi, access_policy_version: nil
136
+ def patch_dataset dataset_id, patched_dataset_gapi, access_policy_version: nil, update_mode: nil
135
137
  patch_with_backoff = false
136
138
  options = {}
137
139
  if patched_dataset_gapi.etag
@@ -141,7 +143,7 @@ module Google
141
143
  end
142
144
  execute backoff: patch_with_backoff do
143
145
  service.patch_dataset @project, dataset_id, patched_dataset_gapi, options: options,
144
- access_policy_version: access_policy_version
146
+ access_policy_version: access_policy_version, update_mode: update_mode
145
147
  end
146
148
  end
147
149