google-cloud-bigquery 1.52.1 → 1.61.1

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
@@ -783,6 +805,14 @@ module Google
783
805
  # `flatten` is false. Optional. The default value is false.
784
806
  # @param [String] session_id The ID of an existing session. See the
785
807
  # `create_session` param in {#query_job} and {Job#session_id}.
808
+ # @param [Boolean] format_options_use_int64_timestamp Output timestamp
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``.
815
+ #
786
816
  # @yield [job] a job configuration object
787
817
  # @yieldparam [Google::Cloud::Bigquery::QueryJob::Updater] job a job
788
818
  # configuration object for setting additional options for the query.
@@ -929,6 +959,8 @@ module Google
929
959
  standard_sql: nil,
930
960
  legacy_sql: nil,
931
961
  session_id: nil,
962
+ format_options_use_int64_timestamp: true,
963
+ reservation: nil,
932
964
  &block
933
965
  job = query_job query,
934
966
  params: params,
@@ -940,6 +972,7 @@ module Google
940
972
  standard_sql: standard_sql,
941
973
  legacy_sql: legacy_sql,
942
974
  session_id: session_id,
975
+ reservation: reservation,
943
976
  &block
944
977
  job.wait_until_done!
945
978
 
@@ -953,7 +986,7 @@ module Google
953
986
  end
954
987
  end
955
988
 
956
- job.data max: max
989
+ job.data max: max, format_options_use_int64_timestamp: format_options_use_int64_timestamp
957
990
  end
958
991
 
959
992
  ##
@@ -1112,6 +1145,56 @@ module Google
1112
1145
  # else the property will be ignored by the backend.
1113
1146
  # @param [string] session_id Session ID in which the load job must run.
1114
1147
  # @param [string] project_id Project ID where the destination table exists.
1148
+ # @param [Boolean] dryrun If set, don't actually run this job. Behavior
1149
+ # is undefined however for non-query jobs and may result in an error.
1150
+ # Deprecated.
1151
+ # @param [String] date_format Format used to parse DATE values.
1152
+ # Supports SQL-style format strings. See
1153
+ # [date and time formatting guide](https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_date_time_as_string)
1154
+ # @param [String] datetime_format Format used to parse DATETIME
1155
+ # values. Supports SQL-style format strings. See
1156
+ # [date and time formatting guide](https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_date_time_as_string)
1157
+ # @param [String] time_format Format used to parse TIME values.
1158
+ # Supports SQL-style format strings. See
1159
+ # [date and time formatting guide](https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_date_time_as_string)
1160
+ # @param [String] timestamp_format Format used to parse
1161
+ # TIMESTAMP values. Supports SQL-style format strings. See
1162
+ # [date and time formatting guide](https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_date_time_as_string)
1163
+ # @param [Array<String>] null_markers A list of strings represented as
1164
+ # SQL NULL value in a CSV file. null_marker and null_markers can't be
1165
+ # set at the same time. If null_marker is set, null_markers has to be
1166
+ # not set. If null_markers is set, null_marker has to be not set. If
1167
+ # both null_marker and null_markers are set at the same time, a user
1168
+ # error would be thrown. Any strings listed in null_markers, including
1169
+ # empty string would be interpreted as SQL NULL. This applies to all
1170
+ # column types.
1171
+ # @param [String] source_column_match Controls the strategy used to
1172
+ # match loaded columns to the schema. If not set, a sensible default is
1173
+ # chosen based on how the schema is provided. If autodetect is used,
1174
+ # then columns are matched by name. Otherwise, columns are matched by
1175
+ # position. This is done to keep the behavior backward-compatible.
1176
+ #
1177
+ # Acceptable values are:
1178
+ # * `POSITION` - matches by position. This assumes that the columns are
1179
+ # ordered the same way as the schema.
1180
+ # * `NAME` - matches by name. This reads the header row as column names
1181
+ # and reorders columns to match the field names in the schema.
1182
+ # @param [String] time_zone The time zone used when parsing timestamp
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``.
1115
1198
  #
1116
1199
  # @yield [updater] A block for setting the schema and other
1117
1200
  # options for the destination table. The schema can be omitted if the
@@ -1119,9 +1202,6 @@ module Google
1119
1202
  # Google Cloud Datastore backup.
1120
1203
  # @yieldparam [Google::Cloud::Bigquery::LoadJob::Updater] updater An
1121
1204
  # updater to modify the load job and its schema.
1122
- # @param [Boolean] dryrun If set, don't actually run this job. Behavior
1123
- # is undefined however for non-query jobs and may result in an error.
1124
- # Deprecated.
1125
1205
  #
1126
1206
  # @return [Google::Cloud::Bigquery::LoadJob] A new load job object.
1127
1207
  #
@@ -1139,7 +1219,10 @@ module Google
1139
1219
  projection_fields: nil, jagged_rows: nil, quoted_newlines: nil, encoding: nil,
1140
1220
  delimiter: nil, ignore_unknown: nil, max_bad_records: nil, quote: nil,
1141
1221
  skip_leading: nil, schema: nil, job_id: nil, prefix: nil, labels: nil, autodetect: nil,
1142
- null_marker: nil, dryrun: nil, create_session: nil, session_id: nil, project_id: nil, &block
1222
+ null_marker: nil, dryrun: nil, create_session: nil, session_id: nil, project_id: nil,
1223
+ date_format: nil, datetime_format: nil, time_format: nil, timestamp_format: nil,
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
1143
1226
  ensure_service!
1144
1227
  dataset_id ||= "_SESSION" unless create_session.nil? && session_id.nil?
1145
1228
  session_dataset = dataset dataset_id, skip_lookup: true, project_id: project_id
@@ -1151,7 +1234,12 @@ module Google
1151
1234
  max_bad_records: max_bad_records, quote: quote, skip_leading: skip_leading,
1152
1235
  dryrun: dryrun, schema: schema, job_id: job_id, prefix: prefix, labels: labels,
1153
1236
  autodetect: autodetect, null_marker: null_marker, create_session: create_session,
1154
- session_id: session_id, &block
1237
+ session_id: session_id, date_format: date_format, datetime_format: datetime_format,
1238
+ time_format: time_format, timestamp_format: timestamp_format,
1239
+ null_markers: null_markers, source_column_match: source_column_match,
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
1155
1243
  end
1156
1244
 
1157
1245
  ##
@@ -1273,6 +1361,53 @@ module Google
1273
1361
  # this option. Also note that for most use cases, the block yielded by
1274
1362
  # this method is a more convenient way to configure the schema.
1275
1363
  # @param [string] session_id Session ID in which the load job must run.
1364
+ # @param [String] date_format Format used to parse DATE values.
1365
+ # Supports SQL-style format strings. See
1366
+ # [date and time formatting guide](https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_date_time_as_string)
1367
+ # @param [String] datetime_format Format used to parse DATETIME
1368
+ # values. Supports SQL-style format strings. See
1369
+ # [date and time formatting guide](https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_date_time_as_string)
1370
+ # @param [String] time_format Format used to parse TIME values.
1371
+ # Supports SQL-style format strings. See
1372
+ # [date and time formatting guide](https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_date_time_as_string)
1373
+ # @param [String] timestamp_format Format used to parse
1374
+ # TIMESTAMP values. Supports SQL-style format strings. See
1375
+ # [date and time formatting guide](https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_date_time_as_string)
1376
+ # @param [Array<String>] null_markers A list of strings represented as
1377
+ # SQL NULL value in a CSV file. null_marker and null_markers can't be
1378
+ # set at the same time. If null_marker is set, null_markers has to be
1379
+ # not set. If null_markers is set, null_marker has to be not set. If
1380
+ # both null_marker and null_markers are set at the same time, a user
1381
+ # error would be thrown. Any strings listed in null_markers, including
1382
+ # empty string would be interpreted as SQL NULL. This applies to all
1383
+ # column types.
1384
+ # @param [String] source_column_match Controls the strategy used to
1385
+ # match loaded columns to the schema. If not set, a sensible default is
1386
+ # chosen based on how the schema is provided. If autodetect is used,
1387
+ # then columns are matched by name. Otherwise, columns are matched by
1388
+ # position. This is done to keep the behavior backward-compatible.
1389
+ #
1390
+ # Acceptable values are:
1391
+ # * `POSITION` - matches by position. This assumes that the columns are
1392
+ # ordered the same way as the schema.
1393
+ # * `NAME` - matches by name. This reads the header row as column names
1394
+ # and reorders columns to match the field names in the schema.
1395
+ # @param [String] time_zone The time zone used when parsing timestamp
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``.
1276
1411
  #
1277
1412
  # @yield [updater] A block for setting the schema of the destination
1278
1413
  # table and other options for the load job. The schema can be omitted
@@ -1302,13 +1437,22 @@ module Google
1302
1437
  def load table_id, files, dataset_id: "_SESSION", format: nil, create: nil, write: nil,
1303
1438
  projection_fields: nil, jagged_rows: nil, quoted_newlines: nil, encoding: nil,
1304
1439
  delimiter: nil, ignore_unknown: nil, max_bad_records: nil, quote: nil,
1305
- skip_leading: nil, schema: nil, autodetect: nil, null_marker: nil, session_id: nil, &block
1440
+ skip_leading: nil, schema: nil, autodetect: nil, null_marker: nil, session_id: nil,
1441
+ date_format: nil, datetime_format: nil, time_format: nil, timestamp_format: nil,
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
1306
1444
  job = load_job table_id, files, dataset_id: dataset_id,
1307
1445
  format: format, create: create, write: write, projection_fields: projection_fields,
1308
1446
  jagged_rows: jagged_rows, quoted_newlines: quoted_newlines, encoding: encoding,
1309
1447
  delimiter: delimiter, ignore_unknown: ignore_unknown, max_bad_records: max_bad_records,
1310
1448
  quote: quote, skip_leading: skip_leading, schema: schema, autodetect: autodetect,
1311
- null_marker: null_marker, session_id: session_id, &block
1449
+ null_marker: null_marker, session_id: session_id, date_format: date_format,
1450
+ datetime_format: datetime_format, time_format: time_format,
1451
+ timestamp_format: timestamp_format, null_markers: null_markers,
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
1312
1456
 
1313
1457
  job.wait_until_done!
1314
1458
  ensure_job_succeeded! job
@@ -1378,6 +1522,27 @@ module Google
1378
1522
  # service. Calls made on this object will raise errors if the resource
1379
1523
  # does not exist. Default is `false`. Optional.
1380
1524
  # @param [String] project_id The GCP Project where the dataset lives.
1525
+ # @param [Integer] access_policy_version Optional. The version of the
1526
+ # provided access policy schema. Valid values are `0`, `1`, and `3`.
1527
+ # Requests specifying an invalid value will be rejected. This
1528
+ # version refers to the schema version of the access policy and not
1529
+ # the version of access policy. This field's value can be equal or
1530
+ # more than the access policy schema provided in the request. For
1531
+ # example, requests with conditional access policy binding in datasets
1532
+ # must specify version `3`. But dataset with no conditional role
1533
+ # bindings in access policy may specify any valid value or leave the
1534
+ # field unset. If unset or if `0` or `1` value is used for dataset with
1535
+ # conditional bindings, request will be rejected. This field will be
1536
+ # mapped to
1537
+ # [IAM Policy version](https://cloud.google.com/iam/docs/policies#versions)
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.
1381
1546
  #
1382
1547
  # @return [Google::Cloud::Bigquery::Dataset, nil] Returns `nil` if the
1383
1548
  # dataset does not exist.
@@ -1405,12 +1570,13 @@ module Google
1405
1570
  #
1406
1571
  # dataset = bigquery.dataset "my_dataset", skip_lookup: true
1407
1572
  #
1408
- def dataset dataset_id, skip_lookup: nil, project_id: nil
1573
+ def dataset dataset_id, skip_lookup: nil, project_id: nil, access_policy_version: nil, dataset_view: nil
1409
1574
  ensure_service!
1410
1575
  project_id ||= project
1411
1576
  return Dataset.new_reference project_id, dataset_id, service if skip_lookup
1412
- gapi = service.get_project_dataset project_id, dataset_id
1413
- Dataset.from_gapi gapi, service
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
1414
1580
  rescue Google::Cloud::NotFoundError
1415
1581
  nil
1416
1582
  end
@@ -1429,6 +1595,28 @@ module Google
1429
1595
  # @param [String] location The geographic location where the dataset
1430
1596
  # should reside. Possible values include `EU` and `US`. The default
1431
1597
  # value is `US`.
1598
+ # @param [Integer] access_policy_version Optional. The version of the
1599
+ # provided access policy schema. Valid values are `0`, `1`, and `3`.
1600
+ # Requests specifying an invalid value will be rejected. This
1601
+ # version refers to the schema version of the access policy and not
1602
+ # the version of access policy. This field's value can be equal or
1603
+ # more than the access policy schema provided in the request. For
1604
+ # example, requests with conditional access policy binding in datasets
1605
+ # must specify version `3`. But dataset with no conditional role
1606
+ # bindings in access policy may specify any valid value or leave the
1607
+ # field unset. If unset or if `0` or `1` value is used for dataset with
1608
+ # conditional bindings, request will be rejected. This field will be
1609
+ # mapped to
1610
+ # [IAM Policy version](https://cloud.google.com/iam/docs/policies#versions)
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
+ #
1432
1620
  # @yield [access] a block for setting rules
1433
1621
  # @yieldparam [Google::Cloud::Bigquery::Dataset] access the object
1434
1622
  # accepting rules
@@ -1461,7 +1649,8 @@ module Google
1461
1649
  # end
1462
1650
  #
1463
1651
  def create_dataset dataset_id, name: nil, description: nil,
1464
- expiration: nil, location: nil
1652
+ expiration: nil, location: nil, access_policy_version: nil,
1653
+ dataset_view: nil
1465
1654
  ensure_service!
1466
1655
 
1467
1656
  new_ds = Google::Apis::BigqueryV2::Dataset.new(
@@ -1484,8 +1673,8 @@ module Google
1484
1673
  updater.check_for_mutated_access!
1485
1674
  end
1486
1675
 
1487
- gapi = service.insert_dataset new_ds
1488
- Dataset.from_gapi gapi, service
1676
+ gapi = service.insert_dataset new_ds, access_policy_version: access_policy_version
1677
+ Dataset.from_gapi gapi, service, access_policy_version: access_policy_version, dataset_view: dataset_view
1489
1678
  end
1490
1679
 
1491
1680
  ##
@@ -1983,6 +2172,12 @@ module Google
1983
2172
  # * The key portion of a label must be unique. However, you can use the
1984
2173
  # same key with multiple resources.
1985
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
+ #
1986
2181
  # @yield [job] a job configuration object
1987
2182
  # @yieldparam [Google::Cloud::Bigquery::ExtractJob::Updater] job a job
1988
2183
  # configuration object for setting additional options.
@@ -2011,10 +2206,10 @@ module Google
2011
2206
  # @!group Data
2012
2207
  #
2013
2208
  def extract_job source, extract_url, format: nil, compression: nil, delimiter: nil, header: nil, job_id: nil,
2014
- prefix: nil, labels: nil
2209
+ prefix: nil, labels: nil, reservation: nil
2015
2210
  ensure_service!
2016
2211
  options = { format: format, compression: compression, delimiter: delimiter, header: header, job_id: job_id,
2017
- prefix: prefix, labels: labels }
2212
+ prefix: prefix, labels: labels, reservation: reservation }
2018
2213
  source_ref = if source.respond_to? :model_ref
2019
2214
  source.model_ref
2020
2215
  else
@@ -2081,6 +2276,12 @@ module Google
2081
2276
  # models.
2082
2277
  # @param [Boolean] header Whether to print out a header row in table
2083
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
+ #
2084
2285
  # @yield [job] a job configuration object
2085
2286
  # @yieldparam [Google::Cloud::Bigquery::ExtractJob::Updater] job a job
2086
2287
  # configuration object for setting additional options.
@@ -2106,12 +2307,14 @@ module Google
2106
2307
  #
2107
2308
  # @!group Data
2108
2309
  #
2109
- 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
2110
2312
  job = extract_job source, extract_url,
2111
2313
  format: format,
2112
2314
  compression: compression,
2113
2315
  delimiter: delimiter,
2114
2316
  header: header,
2317
+ reservation: reservation,
2115
2318
  &block
2116
2319
  job.wait_until_done!
2117
2320
  ensure_job_succeeded! job
@@ -723,6 +723,8 @@ module Google
723
723
  # identifying the result set.
724
724
  # @param [Integer] max Maximum number of results to return.
725
725
  # @param [Integer] start Zero-based index of the starting row to read.
726
+ # @param [Boolean] format_options_use_int64_timestamp Output timestamp
727
+ # as usec int64. Default is true.
726
728
  #
727
729
  # @return [Google::Cloud::Bigquery::Data] An object providing access to
728
730
  # data read from the destination table for the job.
@@ -745,20 +747,21 @@ module Google
745
747
  # # Retrieve the next page of results
746
748
  # data = data.next if data.next?
747
749
  #
748
- def data token: nil, max: nil, start: nil
750
+ def data token: nil, max: nil, start: nil, format_options_use_int64_timestamp: true
749
751
  return nil unless done?
750
- return Data.from_gapi_json({ rows: [] }, nil, @gapi, service) if dryrun?
752
+ return Data.from_gapi_json({ rows: [] }, nil, @gapi, service, format_options_use_int64_timestamp) if dryrun?
751
753
  if ddl? || dml? || !ensure_schema!
752
754
  data_hash = { totalRows: nil, rows: [] }
753
- return Data.from_gapi_json data_hash, nil, @gapi, service
755
+ return Data.from_gapi_json data_hash, nil, @gapi, service, format_options_use_int64_timestamp
754
756
  end
755
757
 
756
758
  data_hash = service.list_tabledata destination_table_dataset_id,
757
759
  destination_table_table_id,
758
760
  token: token,
759
761
  max: max,
760
- start: start
761
- Data.from_gapi_json data_hash, destination_table_gapi, @gapi, service
762
+ start: start,
763
+ format_options_use_int64_timestamp: format_options_use_int64_timestamp
764
+ Data.from_gapi_json data_hash, destination_table_gapi, @gapi, service, format_options_use_int64_timestamp
762
765
  end
763
766
  alias query_results data
764
767
 
@@ -789,7 +792,8 @@ module Google
789
792
  query: query,
790
793
  default_dataset: dataset_config,
791
794
  maximum_billing_tier: options[:maximum_billing_tier]
792
- )
795
+ ),
796
+ reservation: options[:reservation]
793
797
  )
794
798
  )
795
799
 
@@ -1593,6 +1597,18 @@ module Google
1593
1597
  @gapi.configuration.query.clustering.fields = fields
1594
1598
  end
1595
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
+
1596
1612
  def cancel
1597
1613
  raise "not implemented in #{self.class}"
1598
1614
  end
@@ -0,0 +1,156 @@
1
+ # Copyright 2025 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ module Google
16
+ module Cloud
17
+ module Bigquery
18
+ ##
19
+ # # RemoteFunctionOptions
20
+ #
21
+ # Options for a remote user-defined function.
22
+ #
23
+ class RemoteFunctionOptions
24
+ ##
25
+ # @private The Google API Client object.
26
+ # @return [Google::Apis::BigqueryV2::RemoteFunctionOptions]
27
+ attr_accessor :gapi
28
+
29
+ ##
30
+ # Creates a new RemoteFunctionOptions object.
31
+ #
32
+ # @example
33
+ # require "google/cloud/bigquery"
34
+ #
35
+ # remote_function_options = Google::Cloud::Bigquery::RemoteFunctionOptions.new.tap do |rfo|
36
+ # rfo.endpoint = "https://us-east1-my_gcf_project.cloudfunctions.net/remote_add"
37
+ # rfo.connection = "projects/my-project/locations/us-east1/connections/my-connection"
38
+ # rfo.user_defined_context = { "foo" => "bar" }
39
+ # end
40
+ #
41
+ def initialize
42
+ @gapi = Google::Apis::BigqueryV2::RemoteFunctionOptions.new
43
+ end
44
+
45
+ ##
46
+ # The endpoint of the user-provided remote service, e.g.
47
+ # `https://us-east1-my_gcf_project.cloudfunctions.net/remote_add`.
48
+ #
49
+ # @return [String] The endpoint of the user-provided remote service.
50
+ # Returns an empty string if the endpoint is not configured.
51
+ #
52
+ def endpoint
53
+ @gapi.endpoint || ""
54
+ end
55
+
56
+ ##
57
+ # Sets the endpoint of the user-provided remote service.
58
+ #
59
+ # @param [String, nil] new_endpoint The new endpoint. Passing `nil` will
60
+ # clear the endpoint, indicating that no remote service is configured.
61
+ #
62
+ def endpoint= new_endpoint
63
+ @gapi.endpoint = new_endpoint
64
+ end
65
+
66
+ ##
67
+ # The fully qualified name of the user-provided connection object which
68
+ # holds the authentication information to send requests to the remote
69
+ # service.
70
+ #
71
+ # Format:
72
+ # `projects/{projectId}/locations/{locationId}/connections/{connectionId}`
73
+ #
74
+ # @return [String] The fully qualified name of the user-provided
75
+ # connection object. Returns an empty string if the connection is not
76
+ # configured.
77
+ #
78
+ def connection
79
+ @gapi.connection || ""
80
+ end
81
+
82
+ ##
83
+ # Sets the fully qualified name of the user-provided connection object.
84
+ #
85
+ # @param [String, nil] new_connection The new connection. Passing `nil`
86
+ # will clear the connection, indicating that no authentication
87
+ # information is configured for the remote service.
88
+ #
89
+ def connection= new_connection
90
+ @gapi.connection = new_connection
91
+ end
92
+
93
+ ##
94
+ # User-defined context as a set of key/value pairs, which will be sent
95
+ # as function invocation context together with batched arguments in the
96
+ # requests to the remote service. The total number of bytes of keys and
97
+ # values must be less than 8KB.
98
+ #
99
+ # @return [Hash] The user-defined context. Returns an empty hash if no
100
+ # context is configured.
101
+ #
102
+ def user_defined_context
103
+ @gapi.user_defined_context || {}
104
+ end
105
+
106
+ ##
107
+ # Sets the user-defined context.
108
+ #
109
+ # @param [Hash, nil] new_user_defined_context The new user-defined
110
+ # context. Passing `nil` will clear the context, meaning no
111
+ # user-defined key-value pairs will be sent.
112
+ #
113
+ def user_defined_context= new_user_defined_context
114
+ @gapi.user_defined_context = new_user_defined_context
115
+ end
116
+
117
+ ##
118
+ # Max number of rows in each batch sent to the remote service. If absent
119
+ # or if 0, BigQuery dynamically decides the number of rows in a batch.
120
+ #
121
+ # @return [Integer] Max number of rows in each batch. Returns `0` if not
122
+ # set, which indicates that BigQuery dynamically decides the number of
123
+ # rows.
124
+ #
125
+ def max_batching_rows
126
+ @gapi.max_batching_rows || 0
127
+ end
128
+
129
+ ##
130
+ # Sets the max number of rows in each batch sent to the remote service.
131
+ #
132
+ # @param [Integer, nil] new_max_batching_rows The new max batching rows.
133
+ # Passing `nil` or `0` will reset the batch size, indicating that
134
+ # BigQuery should dynamically decide the number of rows in each batch.
135
+ #
136
+ def max_batching_rows= new_max_batching_rows
137
+ @gapi.max_batching_rows = new_max_batching_rows
138
+ end
139
+
140
+ # @private New RemoteFunctionOptions from a Google API Client object.
141
+ def self.from_gapi gapi
142
+ return nil if gapi.nil?
143
+ new.tap do |rfo|
144
+ rfo.instance_variable_set :@gapi, gapi
145
+ end
146
+ end
147
+
148
+ ##
149
+ # @private Returns the Google API Client object.
150
+ def to_gapi
151
+ @gapi
152
+ end
153
+ end
154
+ end
155
+ end
156
+ end