google-cloud-bigquery 1.58.0 → 1.60.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
@@ -2091,6 +2155,12 @@ module Google
2091
2155
  # * The key portion of a label must be unique. However, you can use the
2092
2156
  # same key with multiple resources.
2093
2157
  # * Keys must start with a lowercase letter or international character.
2158
+ # @param [String] reservation The reservation that job would use. User
2159
+ # can specify a reservation to execute the job. If reservation is not
2160
+ # set, reservation is determined based on the rules defined by the
2161
+ # reservation assignments. The expected format is
2162
+ # `projects/`project`/locations/`location`/reservations/`reservation``.
2163
+ #
2094
2164
  # @yield [job] a job configuration object
2095
2165
  # @yieldparam [Google::Cloud::Bigquery::ExtractJob::Updater] job a job
2096
2166
  # configuration object for setting additional options.
@@ -2119,10 +2189,10 @@ module Google
2119
2189
  # @!group Data
2120
2190
  #
2121
2191
  def extract_job source, extract_url, format: nil, compression: nil, delimiter: nil, header: nil, job_id: nil,
2122
- prefix: nil, labels: nil
2192
+ prefix: nil, labels: nil, reservation: nil
2123
2193
  ensure_service!
2124
2194
  options = { format: format, compression: compression, delimiter: delimiter, header: header, job_id: job_id,
2125
- prefix: prefix, labels: labels }
2195
+ prefix: prefix, labels: labels, reservation: reservation }
2126
2196
  source_ref = if source.respond_to? :model_ref
2127
2197
  source.model_ref
2128
2198
  else
@@ -2189,6 +2259,12 @@ module Google
2189
2259
  # models.
2190
2260
  # @param [Boolean] header Whether to print out a header row in table
2191
2261
  # exports. Default is `true`. Not applicable when extracting models.
2262
+ # @param [String] reservation The reservation that job would use. User
2263
+ # can specify a reservation to execute the job. If reservation is not
2264
+ # set, reservation is determined based on the rules defined by the
2265
+ # reservation assignments. The expected format is
2266
+ # `projects/`project`/locations/`location`/reservations/`reservation``.
2267
+ #
2192
2268
  # @yield [job] a job configuration object
2193
2269
  # @yieldparam [Google::Cloud::Bigquery::ExtractJob::Updater] job a job
2194
2270
  # configuration object for setting additional options.
@@ -2214,12 +2290,14 @@ module Google
2214
2290
  #
2215
2291
  # @!group Data
2216
2292
  #
2217
- def extract source, extract_url, format: nil, compression: nil, delimiter: nil, header: nil, &block
2293
+ def extract source, extract_url, format: nil, compression: nil, delimiter: nil, header: nil, reservation: nil,
2294
+ &block
2218
2295
  job = extract_job source, extract_url,
2219
2296
  format: format,
2220
2297
  compression: compression,
2221
2298
  delimiter: delimiter,
2222
2299
  header: header,
2300
+ reservation: reservation,
2223
2301
  &block
2224
2302
  job.wait_until_done!
2225
2303
  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
@@ -351,6 +351,31 @@ module Google
351
351
  @gapi.scale
352
352
  end
353
353
 
354
+ ##
355
+ # The collation of the field.
356
+ #
357
+ # Collation can be set only when the type of field is `STRING`.
358
+ # The following values are supported:
359
+ #
360
+ # * `und:ci`: undetermined locale, case insensitive.
361
+ # * (empty string): Default to case-sensitive behavior.
362
+ #
363
+ # @return [String, nil] The collation for the field, or `nil`.
364
+ #
365
+ def collation
366
+ @gapi.collation
367
+ end
368
+
369
+ ##
370
+ # Updates the collation of the field.
371
+ #
372
+ # @param [String] new_collation The new collation. See {#collation}
373
+ # for supported values.
374
+ #
375
+ def collation= new_collation
376
+ @gapi.update! collation: new_collation
377
+ end
378
+
354
379
  ##
355
380
  # Checks if the type of the field is `STRING`.
356
381
  #
@@ -568,7 +593,7 @@ module Google
568
593
  # @param [Integer] max_length The maximum UTF-8 length of strings
569
594
  # allowed in the field.
570
595
  #
571
- def string name, description: nil, mode: :nullable, policy_tags: nil, max_length: nil
596
+ def string name, description: nil, mode: :nullable, policy_tags: nil, max_length: nil, collation: nil
572
597
  record_check!
573
598
 
574
599
  add_field name,
@@ -576,7 +601,8 @@ module Google
576
601
  description: description,
577
602
  mode: mode,
578
603
  policy_tags: policy_tags,
579
- max_length: max_length
604
+ max_length: max_length,
605
+ collation: collation
580
606
  end
581
607
 
582
608
  ##
@@ -1029,7 +1055,8 @@ module Google
1029
1055
  policy_tags: nil,
1030
1056
  max_length: nil,
1031
1057
  precision: nil,
1032
- scale: nil
1058
+ scale: nil,
1059
+ collation: nil
1033
1060
  frozen_check!
1034
1061
 
1035
1062
  new_gapi = Google::Apis::BigqueryV2::TableFieldSchema.new(
@@ -1046,6 +1073,7 @@ module Google
1046
1073
  new_gapi.max_length = max_length if max_length
1047
1074
  new_gapi.precision = precision if precision
1048
1075
  new_gapi.scale = scale if scale
1076
+ new_gapi.collation = collation if collation
1049
1077
  # Remove any existing field of this name
1050
1078
  @gapi.fields ||= []
1051
1079
  @gapi.fields.reject! { |f| f.name == new_gapi.name }
@@ -318,13 +318,14 @@ module Google
318
318
  # "[CURRENT_DATE(), DATE '2020-01-01'"]
319
319
  #
320
320
  def string name, description: nil, mode: :nullable, policy_tags: nil,
321
- max_length: nil, default_value_expression: nil
321
+ max_length: nil, default_value_expression: nil, collation: nil
322
322
  add_field name, :string,
323
323
  description: description,
324
324
  mode: mode,
325
325
  policy_tags: policy_tags,
326
326
  max_length: max_length,
327
- default_value_expression: default_value_expression
327
+ default_value_expression: default_value_expression,
328
+ collation: collation
328
329
  end
329
330
 
330
331
  ##
@@ -981,7 +982,8 @@ module Google
981
982
  max_length: nil,
982
983
  precision: nil,
983
984
  scale: nil,
984
- default_value_expression: nil
985
+ default_value_expression: nil,
986
+ collation: nil
985
987
  frozen_check!
986
988
 
987
989
  new_gapi = Google::Apis::BigqueryV2::TableFieldSchema.new(
@@ -999,6 +1001,7 @@ module Google
999
1001
  new_gapi.precision = precision if precision
1000
1002
  new_gapi.scale = scale if scale
1001
1003
  new_gapi.default_value_expression = default_value_expression if default_value_expression
1004
+ new_gapi.collation = collation if collation
1002
1005
  # Remove any existing field of this name
1003
1006
  @gapi.fields ||= []
1004
1007
  @gapi.fields.reject! { |f| f.name == new_gapi.name }