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.
- checksums.yaml +4 -4
- data/AUTHENTICATION.md +12 -1
- data/CHANGELOG.md +69 -0
- data/OVERVIEW.md +4 -4
- data/lib/google/cloud/bigquery/condition.rb +218 -0
- data/lib/google/cloud/bigquery/convert.rb +10 -1
- data/lib/google/cloud/bigquery/copy_job.rb +14 -1
- data/lib/google/cloud/bigquery/data.rb +9 -3
- data/lib/google/cloud/bigquery/dataset/access.rb +281 -28
- data/lib/google/cloud/bigquery/dataset.rb +282 -19
- data/lib/google/cloud/bigquery/external/csv_source.rb +218 -0
- data/lib/google/cloud/bigquery/external/data_source.rb +264 -0
- data/lib/google/cloud/bigquery/extract_job.rb +14 -1
- data/lib/google/cloud/bigquery/job.rb +6 -4
- data/lib/google/cloud/bigquery/load_job.rb +227 -0
- data/lib/google/cloud/bigquery/model.rb +15 -4
- data/lib/google/cloud/bigquery/project.rb +226 -23
- data/lib/google/cloud/bigquery/query_job.rb +22 -6
- data/lib/google/cloud/bigquery/remote_function_options.rb +156 -0
- data/lib/google/cloud/bigquery/routine.rb +153 -0
- data/lib/google/cloud/bigquery/schema/field.rb +31 -3
- data/lib/google/cloud/bigquery/schema.rb +6 -3
- data/lib/google/cloud/bigquery/service.rb +19 -12
- data/lib/google/cloud/bigquery/table.rb +326 -29
- data/lib/google/cloud/bigquery/version.rb +1 -1
- data/lib/google/cloud/bigquery.rb +25 -9
- data/lib/google-cloud-bigquery.rb +19 -3
- metadata +15 -7
|
@@ -29,6 +29,48 @@ require "google/apis/bigquery_v2"
|
|
|
29
29
|
module Google
|
|
30
30
|
module Cloud
|
|
31
31
|
module Bigquery
|
|
32
|
+
module DatasetView
|
|
33
|
+
# Provides constants for the dataset_view parameter, an optional field
|
|
34
|
+
# in the GetDatasetRequest used to specify which information about a
|
|
35
|
+
# BigQuery dataset should be returned in the response. By controlling
|
|
36
|
+
# this parameter, users can request a partial or full response, which
|
|
37
|
+
# helps enforce fine-grained access control based on their permissions.
|
|
38
|
+
|
|
39
|
+
# Default. Equivalent to `FULL`. `datasets.get` and `datasets.getIamPolicy` permissions required.
|
|
40
|
+
DATASET_VIEW_UNSPECIFIED = "DATASET_VIEW_UNSPECIFIED".freeze
|
|
41
|
+
|
|
42
|
+
# Returns metadata only. `datasets.get` permission required.
|
|
43
|
+
METADATA = "METADATA".freeze
|
|
44
|
+
|
|
45
|
+
# Returns ACLs only. `datasets.getIamPolicy` permission required.
|
|
46
|
+
ACL = "ACL".freeze
|
|
47
|
+
|
|
48
|
+
# Returns metadata and ACLs. `datasets.get` and `datasets.getIamPolicy` permissions required.
|
|
49
|
+
FULL = "FULL".freeze
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
module UpdateMode
|
|
53
|
+
# Provides constants for the update_mode parameter, an optional field
|
|
54
|
+
# in the PatchDatasetRequest and UpdateDatasetRequest used to specify
|
|
55
|
+
# whether the resource is being updated with full or partial semantics
|
|
56
|
+
# (metadata, ACLs, or both).
|
|
57
|
+
# By controlling this parameter, users can request full or partial
|
|
58
|
+
# update semantics, which helps enforce fine-grained access control
|
|
59
|
+
# based on their permissions.
|
|
60
|
+
|
|
61
|
+
# Default. Equivalent to `UPDATE_FULL`. `datasets.update` and `datasets.setIamPolicy` permissions required.
|
|
62
|
+
UPDATE_MODE_UNSPECIFIED = "UPDATE_MODE_UNSPECIFIED".freeze
|
|
63
|
+
|
|
64
|
+
# Updates both metadata and ACLs. `datasets.update` and `datasets.setIamPolicy` permissions required.
|
|
65
|
+
UPDATE_FULL = "UPDATE_FULL".freeze
|
|
66
|
+
|
|
67
|
+
# Updates only metadata. `datasets.update` permission required.
|
|
68
|
+
UPDATE_METADATA = "UPDATE_METADATA".freeze
|
|
69
|
+
|
|
70
|
+
# Updates only ACLs. `datasets.setIamPolicy` permission required.
|
|
71
|
+
UPDATE_ACL = "UPDATE_ACL".freeze
|
|
72
|
+
end
|
|
73
|
+
|
|
32
74
|
##
|
|
33
75
|
# # Dataset
|
|
34
76
|
#
|
|
@@ -59,12 +101,25 @@ module Google
|
|
|
59
101
|
# @private A Google API Client Dataset Reference object.
|
|
60
102
|
attr_reader :reference
|
|
61
103
|
|
|
104
|
+
##
|
|
105
|
+
# @private Access Policy Version for get, update, patch, and insert API calls
|
|
106
|
+
attr_accessor :access_policy_version
|
|
107
|
+
|
|
108
|
+
##
|
|
109
|
+
# @private The dataset_view parameter is an optional field in the GetDatasetRequest used to specify which
|
|
110
|
+
# information about a BigQuery dataset should be returned in the response. By controlling this parameter, users
|
|
111
|
+
# can request a partial or full response, which helps enforce fine-grained access control based on their
|
|
112
|
+
# permissions.
|
|
113
|
+
attr_accessor :dataset_view
|
|
114
|
+
|
|
62
115
|
##
|
|
63
116
|
# @private Create an empty Dataset object.
|
|
64
117
|
def initialize
|
|
65
118
|
@service = nil
|
|
66
119
|
@gapi = nil
|
|
67
120
|
@reference = nil
|
|
121
|
+
@access_policy_version = nil
|
|
122
|
+
@dataset_view = nil
|
|
68
123
|
end
|
|
69
124
|
|
|
70
125
|
##
|
|
@@ -192,6 +247,37 @@ module Google
|
|
|
192
247
|
patch_gapi! :description
|
|
193
248
|
end
|
|
194
249
|
|
|
250
|
+
##
|
|
251
|
+
# The default collation of the dataset.
|
|
252
|
+
#
|
|
253
|
+
# @return [String, nil] The default collation, or `nil` if not present or the object is a
|
|
254
|
+
# reference (see {#reference?}).
|
|
255
|
+
#
|
|
256
|
+
# @!group Attributes
|
|
257
|
+
#
|
|
258
|
+
def default_collation
|
|
259
|
+
return nil if reference?
|
|
260
|
+
ensure_full_data!
|
|
261
|
+
@gapi.default_collation
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
##
|
|
265
|
+
# Updates the default collation of the dataset.
|
|
266
|
+
#
|
|
267
|
+
# If the dataset is not a full resource representation (see
|
|
268
|
+
# {#resource_full?}), the full representation will be retrieved before
|
|
269
|
+
# the update to comply with ETag-based optimistic concurrency control.
|
|
270
|
+
#
|
|
271
|
+
# @param [String] new_default_collation The new default collation for the dataset.
|
|
272
|
+
#
|
|
273
|
+
# @!group Attributes
|
|
274
|
+
#
|
|
275
|
+
def default_collation= new_default_collation
|
|
276
|
+
reload! unless resource_full?
|
|
277
|
+
@gapi.update! default_collation: new_default_collation
|
|
278
|
+
patch_gapi! :default_collation
|
|
279
|
+
end
|
|
280
|
+
|
|
195
281
|
##
|
|
196
282
|
# The default lifetime of all tables in the dataset, in milliseconds.
|
|
197
283
|
#
|
|
@@ -1388,6 +1474,12 @@ module Google
|
|
|
1388
1474
|
# The default value is false.
|
|
1389
1475
|
# @param [String] session_id The ID of an existing session. See also the
|
|
1390
1476
|
# `create_session` param and {Job#session_id}.
|
|
1477
|
+
# @param [String] reservation The reservation that job would use. User
|
|
1478
|
+
# can specify a reservation to execute the job. If reservation is not
|
|
1479
|
+
# set, reservation is determined based on the rules defined by the
|
|
1480
|
+
# reservation assignments. The expected format is
|
|
1481
|
+
# `projects/`project`/locations/`location`/reservations/`reservation``.
|
|
1482
|
+
#
|
|
1391
1483
|
# @yield [job] a job configuration object
|
|
1392
1484
|
# @yieldparam [Google::Cloud::Bigquery::QueryJob::Updater] job a job
|
|
1393
1485
|
# configuration object for setting additional options for the query.
|
|
@@ -1560,7 +1652,8 @@ module Google
|
|
|
1560
1652
|
labels: nil,
|
|
1561
1653
|
udfs: nil,
|
|
1562
1654
|
create_session: nil,
|
|
1563
|
-
session_id: nil
|
|
1655
|
+
session_id: nil,
|
|
1656
|
+
reservation: nil
|
|
1564
1657
|
ensure_service!
|
|
1565
1658
|
options = {
|
|
1566
1659
|
params: params,
|
|
@@ -1583,7 +1676,8 @@ module Google
|
|
|
1583
1676
|
labels: labels,
|
|
1584
1677
|
udfs: udfs,
|
|
1585
1678
|
create_session: create_session,
|
|
1586
|
-
session_id: session_id
|
|
1679
|
+
session_id: session_id,
|
|
1680
|
+
reservation: reservation
|
|
1587
1681
|
}
|
|
1588
1682
|
|
|
1589
1683
|
updater = QueryJob::Updater.from_options service, query, options
|
|
@@ -1710,6 +1804,14 @@ module Google
|
|
|
1710
1804
|
# `flatten` is false. Optional. The default value is false.
|
|
1711
1805
|
# @param [String] session_id The ID of an existing session. See the
|
|
1712
1806
|
# `create_session` param in {#query_job} and {Job#session_id}.
|
|
1807
|
+
# @param [Boolean] format_options_use_int64_timestamp Output timestamp
|
|
1808
|
+
# as usec int64. Default is true.
|
|
1809
|
+
# @param [String] reservation The reservation that job would use. User
|
|
1810
|
+
# can specify a reservation to execute the job. If reservation is not
|
|
1811
|
+
# set, reservation is determined based on the rules defined by the
|
|
1812
|
+
# reservation assignments. The expected format is
|
|
1813
|
+
# `projects/`project`/locations/`location`/reservations/`reservation``.
|
|
1814
|
+
#
|
|
1713
1815
|
# @yield [job] a job configuration object
|
|
1714
1816
|
# @yieldparam [Google::Cloud::Bigquery::QueryJob::Updater] job a job
|
|
1715
1817
|
# configuration object for setting additional options for the query.
|
|
@@ -1864,6 +1966,8 @@ module Google
|
|
|
1864
1966
|
standard_sql: nil,
|
|
1865
1967
|
legacy_sql: nil,
|
|
1866
1968
|
session_id: nil,
|
|
1969
|
+
format_options_use_int64_timestamp: true,
|
|
1970
|
+
reservation: nil,
|
|
1867
1971
|
&block
|
|
1868
1972
|
job = query_job query,
|
|
1869
1973
|
params: params,
|
|
@@ -1873,11 +1977,12 @@ module Google
|
|
|
1873
1977
|
standard_sql: standard_sql,
|
|
1874
1978
|
legacy_sql: legacy_sql,
|
|
1875
1979
|
session_id: session_id,
|
|
1980
|
+
reservation: reservation,
|
|
1876
1981
|
&block
|
|
1877
1982
|
job.wait_until_done!
|
|
1878
1983
|
ensure_job_succeeded! job
|
|
1879
1984
|
|
|
1880
|
-
job.data max: max
|
|
1985
|
+
job.data max: max, format_options_use_int64_timestamp: format_options_use_int64_timestamp
|
|
1881
1986
|
end
|
|
1882
1987
|
|
|
1883
1988
|
##
|
|
@@ -2091,6 +2196,53 @@ module Google
|
|
|
2091
2196
|
# and the load job will happen in the table created within that session.
|
|
2092
2197
|
# Note: This will work only for _SESSION dataset.
|
|
2093
2198
|
# @param [string] session_id Session ID in which the load job must run.
|
|
2199
|
+
# @param [String] date_format Format used to parse DATE values.
|
|
2200
|
+
# Supports SQL-style format strings. See
|
|
2201
|
+
# [date and time formatting guide](https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_date_time_as_string)
|
|
2202
|
+
# @param [String] datetime_format Format used to parse DATETIME
|
|
2203
|
+
# values. Supports SQL-style format strings. See
|
|
2204
|
+
# [date and time formatting guide](https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_date_time_as_string)
|
|
2205
|
+
# @param [String] time_format Format used to parse TIME values.
|
|
2206
|
+
# Supports SQL-style format strings. See
|
|
2207
|
+
# [date and time formatting guide](https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_date_time_as_string)
|
|
2208
|
+
# @param [String] timestamp_format Format used to parse
|
|
2209
|
+
# TIMESTAMP values. Supports SQL-style format strings. See
|
|
2210
|
+
# [date and time formatting guide](https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_date_time_as_string)
|
|
2211
|
+
# @param [Array<String>] null_markers A list of strings represented as
|
|
2212
|
+
# SQL NULL value in a CSV file. null_marker and null_markers can't be
|
|
2213
|
+
# set at the same time. If null_marker is set, null_markers has to be
|
|
2214
|
+
# not set. If null_markers is set, null_marker has to be not set. If
|
|
2215
|
+
# both null_marker and null_markers are set at the same time, a user
|
|
2216
|
+
# error would be thrown. Any strings listed in null_markers, including
|
|
2217
|
+
# empty string would be interpreted as SQL NULL. This applies to all
|
|
2218
|
+
# column types.
|
|
2219
|
+
# @param [String] source_column_match Controls the strategy used to
|
|
2220
|
+
# match loaded columns to the schema. If not set, a sensible default is
|
|
2221
|
+
# chosen based on how the schema is provided. If autodetect is used,
|
|
2222
|
+
# then columns are matched by name. Otherwise, columns are matched by
|
|
2223
|
+
# position. This is done to keep the behavior backward-compatible.
|
|
2224
|
+
#
|
|
2225
|
+
# Acceptable values are:
|
|
2226
|
+
# * `POSITION` - matches by position. This assumes that the columns are
|
|
2227
|
+
# ordered the same way as the schema.
|
|
2228
|
+
# * `NAME` - matches by name. This reads the header row as column names
|
|
2229
|
+
# and reorders columns to match the field names in the schema.
|
|
2230
|
+
# @param [String] time_zone The time zone used when parsing timestamp
|
|
2231
|
+
# values.
|
|
2232
|
+
# @param [String] reference_file_schema_uri The URI of the reference
|
|
2233
|
+
# file with the reader schema. This file is only loaded if it is part
|
|
2234
|
+
# of source URIs, but is not loaded otherwise. It is enabled for the
|
|
2235
|
+
# following formats: `AVRO`, `PARQUET`, `ORC`.
|
|
2236
|
+
# @param [Boolean] preserve_ascii_control_characters When source_format
|
|
2237
|
+
# is set to `CSV`, indicates if the embedded ASCII control characters
|
|
2238
|
+
# (the first 32 characters in the ASCII-table, from `\x00` to `\x1F`)
|
|
2239
|
+
# are preserved. By default, ASCII control characters are not
|
|
2240
|
+
# preserved.
|
|
2241
|
+
# @param [String] reservation The reservation that job would use. User
|
|
2242
|
+
# can specify a reservation to execute the job. If reservation is not
|
|
2243
|
+
# set, reservation is determined based on the rules defined by the
|
|
2244
|
+
# reservation assignments. The expected format is
|
|
2245
|
+
# `projects/`project`/locations/`location`/reservations/`reservation``.
|
|
2094
2246
|
#
|
|
2095
2247
|
# @yield [updater] A block for setting the schema and other
|
|
2096
2248
|
# options for the destination table. The schema can be omitted if the
|
|
@@ -2185,7 +2337,10 @@ module Google
|
|
|
2185
2337
|
def load_job table_id, files, format: nil, create: nil, write: nil, projection_fields: nil, jagged_rows: nil,
|
|
2186
2338
|
quoted_newlines: nil, encoding: nil, delimiter: nil, ignore_unknown: nil, max_bad_records: nil,
|
|
2187
2339
|
quote: nil, skip_leading: nil, schema: nil, job_id: nil, prefix: nil, labels: nil, autodetect: nil,
|
|
2188
|
-
null_marker: nil, dryrun: nil, create_session: nil, session_id: nil
|
|
2340
|
+
null_marker: nil, dryrun: nil, create_session: nil, session_id: nil, date_format: nil,
|
|
2341
|
+
datetime_format: nil, time_format: nil, timestamp_format: nil, null_markers: nil,
|
|
2342
|
+
source_column_match: nil, time_zone: nil, reference_file_schema_uri: nil,
|
|
2343
|
+
preserve_ascii_control_characters: nil, reservation: nil
|
|
2189
2344
|
ensure_service!
|
|
2190
2345
|
|
|
2191
2346
|
updater = load_job_updater table_id,
|
|
@@ -2195,7 +2350,13 @@ module Google
|
|
|
2195
2350
|
max_bad_records: max_bad_records, quote: quote, skip_leading: skip_leading,
|
|
2196
2351
|
dryrun: dryrun, schema: schema, job_id: job_id, prefix: prefix, labels: labels,
|
|
2197
2352
|
autodetect: autodetect, null_marker: null_marker, create_session: create_session,
|
|
2198
|
-
session_id: session_id
|
|
2353
|
+
session_id: session_id, date_format: date_format, datetime_format: datetime_format,
|
|
2354
|
+
time_format: time_format, timestamp_format: timestamp_format,
|
|
2355
|
+
null_markers: null_markers, source_column_match: source_column_match,
|
|
2356
|
+
time_zone: time_zone, reference_file_schema_uri: reference_file_schema_uri,
|
|
2357
|
+
preserve_ascii_control_characters: preserve_ascii_control_characters,
|
|
2358
|
+
reservation: reservation
|
|
2359
|
+
|
|
2199
2360
|
|
|
2200
2361
|
yield updater if block_given?
|
|
2201
2362
|
|
|
@@ -2322,7 +2483,53 @@ module Google
|
|
|
2322
2483
|
# this option. Also note that for most use cases, the block yielded by
|
|
2323
2484
|
# this method is a more convenient way to configure the schema.
|
|
2324
2485
|
# @param [string] session_id Session ID in which the load job must run.
|
|
2325
|
-
#
|
|
2486
|
+
# @param [String] date_format Format used to parse DATE values.
|
|
2487
|
+
# Supports SQL-style format strings. See
|
|
2488
|
+
# [date and time formatting guide](https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_date_time_as_string)
|
|
2489
|
+
# @param [String] datetime_format Format used to parse DATETIME
|
|
2490
|
+
# values. Supports SQL-style format strings. See
|
|
2491
|
+
# [date and time formatting guide](https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_date_time_as_string)
|
|
2492
|
+
# @param [String] time_format Format used to parse TIME values.
|
|
2493
|
+
# Supports SQL-style format strings. See
|
|
2494
|
+
# [date and time formatting guide](https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_date_time_as_string)
|
|
2495
|
+
# @param [String] timestamp_format Format used to parse
|
|
2496
|
+
# TIMESTAMP values. Supports SQL-style format strings. See
|
|
2497
|
+
# [date and time formatting guide](https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_date_time_as_string)
|
|
2498
|
+
# @param [Array<String>] null_markers A list of strings represented as
|
|
2499
|
+
# SQL NULL value in a CSV file. null_marker and null_markers can't be
|
|
2500
|
+
# set at the same time. If null_marker is set, null_markers has to be
|
|
2501
|
+
# not set. If null_markers is set, null_marker has to be not set. If
|
|
2502
|
+
# both null_marker and null_markers are set at the same time, a user
|
|
2503
|
+
# error would be thrown. Any strings listed in null_markers, including
|
|
2504
|
+
# empty string would be interpreted as SQL NULL. This applies to all
|
|
2505
|
+
# column types.
|
|
2506
|
+
# @param [String] source_column_match Controls the strategy used to
|
|
2507
|
+
# match loaded columns to the schema. If not set, a sensible default is
|
|
2508
|
+
# chosen based on how the schema is provided. If autodetect is used,
|
|
2509
|
+
# then columns are matched by name. Otherwise, columns are matched by
|
|
2510
|
+
# position. This is done to keep the behavior backward-compatible.
|
|
2511
|
+
#
|
|
2512
|
+
# Acceptable values are:
|
|
2513
|
+
# * `POSITION` - matches by position. This assumes that the columns are
|
|
2514
|
+
# ordered the same way as the schema.
|
|
2515
|
+
# * `NAME` - matches by name. This reads the header row as column names
|
|
2516
|
+
# and reorders columns to match the field names in the schema.
|
|
2517
|
+
# @param [String] time_zone The time zone used when parsing timestamp
|
|
2518
|
+
# values.
|
|
2519
|
+
# @param [String] reference_file_schema_uri The URI of the reference
|
|
2520
|
+
# file with the reader schema. This file is only loaded if it is part
|
|
2521
|
+
# of source URIs, but is not loaded otherwise. It is enabled for the
|
|
2522
|
+
# following formats: `AVRO`, `PARQUET`, `ORC`.
|
|
2523
|
+
# @param [Boolean] preserve_ascii_control_characters When source_format
|
|
2524
|
+
# is set to `CSV`, indicates if the embedded ASCII control characters
|
|
2525
|
+
# (the first 32 characters in the ASCII-table, from `\x00` to `\x1F`)
|
|
2526
|
+
# are preserved. By default, ASCII control characters are not
|
|
2527
|
+
# preserved.
|
|
2528
|
+
# @param [String] reservation The reservation that job would use. User
|
|
2529
|
+
# can specify a reservation to execute the job. If reservation is not
|
|
2530
|
+
# set, reservation is determined based on the rules defined by the
|
|
2531
|
+
# reservation assignments. The expected format is
|
|
2532
|
+
# `projects/`project`/locations/`location`/reservations/`reservation``.
|
|
2326
2533
|
#
|
|
2327
2534
|
# @yield [updater] A block for setting the schema of the destination
|
|
2328
2535
|
# table and other options for the load job. The schema can be omitted
|
|
@@ -2415,13 +2622,22 @@ module Google
|
|
|
2415
2622
|
#
|
|
2416
2623
|
def load table_id, files, format: nil, create: nil, write: nil, projection_fields: nil, jagged_rows: nil,
|
|
2417
2624
|
quoted_newlines: nil, encoding: nil, delimiter: nil, ignore_unknown: nil, max_bad_records: nil,
|
|
2418
|
-
quote: nil, skip_leading: nil, schema: nil, autodetect: nil, null_marker: nil, session_id: nil,
|
|
2625
|
+
quote: nil, skip_leading: nil, schema: nil, autodetect: nil, null_marker: nil, session_id: nil,
|
|
2626
|
+
date_format: nil, datetime_format: nil, time_format: nil, timestamp_format: nil,
|
|
2627
|
+
null_markers: nil, source_column_match: nil, time_zone: nil, reference_file_schema_uri: nil,
|
|
2628
|
+
preserve_ascii_control_characters: nil,
|
|
2629
|
+
reservation: nil, &block
|
|
2419
2630
|
job = load_job table_id, files,
|
|
2420
2631
|
format: format, create: create, write: write, projection_fields: projection_fields,
|
|
2421
2632
|
jagged_rows: jagged_rows, quoted_newlines: quoted_newlines, encoding: encoding,
|
|
2422
2633
|
delimiter: delimiter, ignore_unknown: ignore_unknown, max_bad_records: max_bad_records,
|
|
2423
2634
|
quote: quote, skip_leading: skip_leading, schema: schema, autodetect: autodetect,
|
|
2424
|
-
null_marker: null_marker, session_id: session_id,
|
|
2635
|
+
null_marker: null_marker, session_id: session_id, date_format: date_format,
|
|
2636
|
+
datetime_format: datetime_format, time_format: time_format, timestamp_format: timestamp_format,
|
|
2637
|
+
null_markers: null_markers, source_column_match: source_column_match, time_zone: time_zone,
|
|
2638
|
+
reference_file_schema_uri: reference_file_schema_uri,
|
|
2639
|
+
preserve_ascii_control_characters: preserve_ascii_control_characters,
|
|
2640
|
+
reservation: reservation, &block
|
|
2425
2641
|
|
|
2426
2642
|
job.wait_until_done!
|
|
2427
2643
|
ensure_job_succeeded! job
|
|
@@ -2444,7 +2660,8 @@ module Google
|
|
|
2444
2660
|
#
|
|
2445
2661
|
def reload!
|
|
2446
2662
|
ensure_service!
|
|
2447
|
-
@gapi = service.get_project_dataset project_id, dataset_id
|
|
2663
|
+
@gapi = service.get_project_dataset project_id, dataset_id, access_policy_version: @access_policy_version,
|
|
2664
|
+
dataset_view: @dataset_view
|
|
2448
2665
|
@reference = nil
|
|
2449
2666
|
@exists = nil
|
|
2450
2667
|
self
|
|
@@ -2573,10 +2790,12 @@ module Google
|
|
|
2573
2790
|
|
|
2574
2791
|
##
|
|
2575
2792
|
# @private New Dataset from a Google API Client object.
|
|
2576
|
-
def self.from_gapi gapi, conn
|
|
2793
|
+
def self.from_gapi gapi, conn, access_policy_version: nil, dataset_view: nil
|
|
2577
2794
|
new.tap do |f|
|
|
2578
2795
|
f.gapi = gapi
|
|
2579
2796
|
f.service = conn
|
|
2797
|
+
f.access_policy_version = access_policy_version
|
|
2798
|
+
f.dataset_view = dataset_view
|
|
2580
2799
|
end
|
|
2581
2800
|
end
|
|
2582
2801
|
|
|
@@ -2897,10 +3116,25 @@ module Google
|
|
|
2897
3116
|
def patch_gapi! *attributes
|
|
2898
3117
|
return if attributes.empty?
|
|
2899
3118
|
ensure_service!
|
|
3119
|
+
|
|
2900
3120
|
patch_args = attributes.to_h { |attr| [attr, @gapi.send(attr)] }
|
|
3121
|
+
|
|
3122
|
+
update_mode = nil
|
|
3123
|
+
has_access_key = patch_args.key? :access
|
|
3124
|
+
other_keys_exist = (patch_args.keys - [:access]).any?
|
|
3125
|
+
|
|
3126
|
+
if has_access_key && !other_keys_exist
|
|
3127
|
+
update_mode = UpdateMode::UPDATE_ACL
|
|
3128
|
+
elsif !has_access_key && other_keys_exist
|
|
3129
|
+
update_mode = UpdateMode::UPDATE_METADATA
|
|
3130
|
+
elsif has_access_key && other_keys_exist
|
|
3131
|
+
update_mode = UpdateMode::FULL
|
|
3132
|
+
end
|
|
3133
|
+
|
|
2901
3134
|
patch_gapi = Google::Apis::BigqueryV2::Dataset.new(**patch_args)
|
|
2902
3135
|
patch_gapi.etag = etag if etag
|
|
2903
|
-
@gapi = service.patch_dataset dataset_id, patch_gapi
|
|
3136
|
+
@gapi = service.patch_dataset dataset_id, patch_gapi, access_policy_version: @access_policy_version,
|
|
3137
|
+
update_mode: update_mode
|
|
2904
3138
|
end
|
|
2905
3139
|
|
|
2906
3140
|
##
|
|
@@ -2921,7 +3155,7 @@ module Google
|
|
|
2921
3155
|
end
|
|
2922
3156
|
end
|
|
2923
3157
|
|
|
2924
|
-
def load_job_gapi table_id, dryrun, job_id: nil, prefix: nil
|
|
3158
|
+
def load_job_gapi table_id, dryrun, job_id: nil, prefix: nil, reservation: nil
|
|
2925
3159
|
job_ref = service.job_ref_from job_id, prefix
|
|
2926
3160
|
Google::Apis::BigqueryV2::Job.new(
|
|
2927
3161
|
job_reference: job_ref,
|
|
@@ -2933,43 +3167,63 @@ module Google
|
|
|
2933
3167
|
table_id: table_id
|
|
2934
3168
|
)
|
|
2935
3169
|
),
|
|
2936
|
-
dry_run: dryrun
|
|
3170
|
+
dry_run: dryrun,
|
|
3171
|
+
reservation: reservation
|
|
2937
3172
|
)
|
|
2938
3173
|
)
|
|
2939
3174
|
end
|
|
2940
3175
|
|
|
2941
3176
|
def load_job_csv_options! job, jagged_rows: nil, quoted_newlines: nil, delimiter: nil, quote: nil,
|
|
2942
|
-
skip_leading: nil, null_marker: nil
|
|
3177
|
+
skip_leading: nil, null_marker: nil, null_markers: nil, source_column_match: nil,
|
|
3178
|
+
preserve_ascii_control_characters: nil
|
|
2943
3179
|
job.jagged_rows = jagged_rows unless jagged_rows.nil?
|
|
2944
3180
|
job.quoted_newlines = quoted_newlines unless quoted_newlines.nil?
|
|
2945
3181
|
job.delimiter = delimiter unless delimiter.nil?
|
|
2946
3182
|
job.null_marker = null_marker unless null_marker.nil?
|
|
2947
3183
|
job.quote = quote unless quote.nil?
|
|
2948
3184
|
job.skip_leading = skip_leading unless skip_leading.nil?
|
|
3185
|
+
job.null_markers = null_markers unless null_markers.nil?
|
|
3186
|
+
job.source_column_match = source_column_match unless source_column_match.nil?
|
|
3187
|
+
job.preserve_ascii_control_characters = preserve_ascii_control_characters unless
|
|
3188
|
+
preserve_ascii_control_characters.nil?
|
|
2949
3189
|
end
|
|
2950
3190
|
|
|
2951
3191
|
def load_job_file_options! job, format: nil, projection_fields: nil, jagged_rows: nil, quoted_newlines: nil,
|
|
2952
3192
|
encoding: nil, delimiter: nil, ignore_unknown: nil, max_bad_records: nil, quote: nil,
|
|
2953
|
-
skip_leading: nil, null_marker: nil
|
|
3193
|
+
skip_leading: nil, null_marker: nil, date_format: nil, datetime_format: nil,
|
|
3194
|
+
time_format: nil, timestamp_format: nil, null_markers: nil, source_column_match: nil,
|
|
3195
|
+
time_zone: nil, reference_file_schema_uri: nil,
|
|
3196
|
+
preserve_ascii_control_characters: nil
|
|
2954
3197
|
job.format = format unless format.nil?
|
|
2955
3198
|
job.projection_fields = projection_fields unless projection_fields.nil?
|
|
2956
3199
|
job.encoding = encoding unless encoding.nil?
|
|
2957
3200
|
job.ignore_unknown = ignore_unknown unless ignore_unknown.nil?
|
|
2958
3201
|
job.max_bad_records = max_bad_records unless max_bad_records.nil?
|
|
3202
|
+
job.date_format = date_format unless date_format.nil?
|
|
3203
|
+
job.datetime_format = datetime_format unless datetime_format.nil?
|
|
3204
|
+
job.time_format = time_format unless time_format.nil?
|
|
3205
|
+
job.timestamp_format = timestamp_format unless timestamp_format.nil?
|
|
3206
|
+
job.time_zone = time_zone unless time_zone.nil?
|
|
3207
|
+
job.reference_file_schema_uri = reference_file_schema_uri unless reference_file_schema_uri.nil?
|
|
2959
3208
|
load_job_csv_options! job, jagged_rows: jagged_rows,
|
|
2960
3209
|
quoted_newlines: quoted_newlines,
|
|
2961
3210
|
delimiter: delimiter,
|
|
2962
3211
|
quote: quote,
|
|
2963
3212
|
skip_leading: skip_leading,
|
|
2964
|
-
null_marker: null_marker
|
|
3213
|
+
null_marker: null_marker,
|
|
3214
|
+
null_markers: null_markers,
|
|
3215
|
+
source_column_match: source_column_match,
|
|
3216
|
+
preserve_ascii_control_characters: preserve_ascii_control_characters
|
|
2965
3217
|
end
|
|
2966
3218
|
|
|
2967
3219
|
def load_job_updater table_id, format: nil, create: nil, write: nil, projection_fields: nil, jagged_rows: nil,
|
|
2968
3220
|
quoted_newlines: nil, encoding: nil, delimiter: nil, ignore_unknown: nil,
|
|
2969
3221
|
max_bad_records: nil, quote: nil, skip_leading: nil, dryrun: nil, schema: nil, job_id: nil,
|
|
2970
3222
|
prefix: nil, labels: nil, autodetect: nil, null_marker: nil, create_session: nil,
|
|
2971
|
-
session_id: nil
|
|
2972
|
-
|
|
3223
|
+
session_id: nil, date_format: nil, datetime_format: nil, time_format: nil,
|
|
3224
|
+
timestamp_format: nil, null_markers: nil, source_column_match: nil, time_zone: nil,
|
|
3225
|
+
reference_file_schema_uri: nil, preserve_ascii_control_characters: nil, reservation: nil
|
|
3226
|
+
new_job = load_job_gapi table_id, dryrun, job_id: job_id, prefix: prefix, reservation: reservation
|
|
2973
3227
|
LoadJob::Updater.new(new_job).tap do |job|
|
|
2974
3228
|
job.location = location if location # may be dataset reference
|
|
2975
3229
|
job.create = create unless create.nil?
|
|
@@ -2989,7 +3243,16 @@ module Google
|
|
|
2989
3243
|
max_bad_records: max_bad_records,
|
|
2990
3244
|
quote: quote,
|
|
2991
3245
|
skip_leading: skip_leading,
|
|
2992
|
-
null_marker: null_marker
|
|
3246
|
+
null_marker: null_marker,
|
|
3247
|
+
date_format: date_format,
|
|
3248
|
+
datetime_format: datetime_format,
|
|
3249
|
+
time_format: time_format,
|
|
3250
|
+
timestamp_format: timestamp_format,
|
|
3251
|
+
null_markers: null_markers,
|
|
3252
|
+
source_column_match: source_column_match,
|
|
3253
|
+
time_zone: time_zone,
|
|
3254
|
+
reference_file_schema_uri: reference_file_schema_uri,
|
|
3255
|
+
preserve_ascii_control_characters: preserve_ascii_control_characters
|
|
2993
3256
|
end
|
|
2994
3257
|
end
|
|
2995
3258
|
|