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
|
@@ -18,6 +18,7 @@ require "google/cloud/bigquery/convert"
|
|
|
18
18
|
require "google/cloud/bigquery/service"
|
|
19
19
|
require "google/cloud/bigquery/routine/list"
|
|
20
20
|
require "google/cloud/bigquery/argument"
|
|
21
|
+
require "google/cloud/bigquery/remote_function_options"
|
|
21
22
|
|
|
22
23
|
module Google
|
|
23
24
|
module Cloud
|
|
@@ -690,6 +691,108 @@ module Google
|
|
|
690
691
|
@gapi.determinism_level == "NOT_DETERMINISTIC"
|
|
691
692
|
end
|
|
692
693
|
|
|
694
|
+
##
|
|
695
|
+
# The data governance type of the routine. Optional.
|
|
696
|
+
#
|
|
697
|
+
# If set to `DATA_MASKING`, the function is validated and made
|
|
698
|
+
# available as a masking function. For more information, see [Create custom
|
|
699
|
+
# masking routines](https://cloud.google.com/bigquery/docs/user-defined-functions#custom-mask).
|
|
700
|
+
#
|
|
701
|
+
# @return [String, nil] The data governance type, or `nil` if not set or the object is a reference
|
|
702
|
+
# (see {#reference?}).
|
|
703
|
+
#
|
|
704
|
+
# @example
|
|
705
|
+
# require "google/cloud/bigquery"
|
|
706
|
+
#
|
|
707
|
+
# bigquery = Google::Cloud::Bigquery.new
|
|
708
|
+
# dataset = bigquery.dataset "my_dataset"
|
|
709
|
+
# routine = dataset.routine "my_routine"
|
|
710
|
+
#
|
|
711
|
+
# routine.data_governance_type #=> "DATA_MASKING"
|
|
712
|
+
#
|
|
713
|
+
# @!group Attributes
|
|
714
|
+
#
|
|
715
|
+
def data_governance_type
|
|
716
|
+
return nil if reference?
|
|
717
|
+
ensure_full_data!
|
|
718
|
+
@gapi.data_governance_type
|
|
719
|
+
end
|
|
720
|
+
|
|
721
|
+
##
|
|
722
|
+
# Updates the data governance type of the routine. Optional.
|
|
723
|
+
#
|
|
724
|
+
# If set to `DATA_MASKING`, the function is validated and made
|
|
725
|
+
# available as a masking function. For more information, see [Create custom
|
|
726
|
+
# masking routines](https://cloud.google.com/bigquery/docs/user-defined-functions#custom-mask).
|
|
727
|
+
#
|
|
728
|
+
# @param [String, nil] new_data_governance_type The new data governance type. `nil` to unset.
|
|
729
|
+
#
|
|
730
|
+
# @example
|
|
731
|
+
# require "google/cloud/bigquery"
|
|
732
|
+
#
|
|
733
|
+
# bigquery = Google::Cloud::Bigquery.new
|
|
734
|
+
# dataset = bigquery.dataset "my_dataset"
|
|
735
|
+
# routine = dataset.routine "my_routine"
|
|
736
|
+
#
|
|
737
|
+
# routine.data_governance_type = "DATA_MASKING"
|
|
738
|
+
#
|
|
739
|
+
# @!group Attributes
|
|
740
|
+
#
|
|
741
|
+
def data_governance_type= new_data_governance_type
|
|
742
|
+
ensure_full_data!
|
|
743
|
+
@gapi.data_governance_type = new_data_governance_type
|
|
744
|
+
update_gapi!
|
|
745
|
+
end
|
|
746
|
+
|
|
747
|
+
##
|
|
748
|
+
# Remote function specific options. Optional.
|
|
749
|
+
#
|
|
750
|
+
# @return [RemoteFunctionOptions, nil] The remote function options, or `nil` if not set or the object is a
|
|
751
|
+
# reference (see {#reference?}).
|
|
752
|
+
#
|
|
753
|
+
# @example
|
|
754
|
+
# require "google/cloud/bigquery"
|
|
755
|
+
#
|
|
756
|
+
# bigquery = Google::Cloud::Bigquery.new
|
|
757
|
+
# dataset = bigquery.dataset "my_dataset"
|
|
758
|
+
# routine = dataset.routine "my_routine"
|
|
759
|
+
#
|
|
760
|
+
# puts routine.remote_function_options.endpoint
|
|
761
|
+
#
|
|
762
|
+
# @!group Attributes
|
|
763
|
+
#
|
|
764
|
+
def remote_function_options
|
|
765
|
+
return nil if reference?
|
|
766
|
+
ensure_full_data!
|
|
767
|
+
RemoteFunctionOptions.from_gapi @gapi.remote_function_options
|
|
768
|
+
end
|
|
769
|
+
|
|
770
|
+
##
|
|
771
|
+
# Updates the remote function specific options. Optional.
|
|
772
|
+
#
|
|
773
|
+
# @param [RemoteFunctionOptions] new_remote_function_options The new remote function options.
|
|
774
|
+
#
|
|
775
|
+
# @example
|
|
776
|
+
# require "google/cloud/bigquery"
|
|
777
|
+
#
|
|
778
|
+
# bigquery = Google::Cloud::Bigquery.new
|
|
779
|
+
# dataset = bigquery.dataset "my_dataset"
|
|
780
|
+
# routine = dataset.routine "my_routine"
|
|
781
|
+
#
|
|
782
|
+
# rfo = Google::Cloud::Bigquery::RemoteFunctionOptions.new.tap do |rfo|
|
|
783
|
+
# rfo.endpoint = "https://us-east1-my_gcf_project.cloudfunctions.net/remote_add"
|
|
784
|
+
# rfo.connection = "projects/my-project/locations/us-east1/connections/my-connection"
|
|
785
|
+
# end
|
|
786
|
+
# routine.remote_function_options = rfo
|
|
787
|
+
#
|
|
788
|
+
# @!group Attributes
|
|
789
|
+
#
|
|
790
|
+
def remote_function_options= new_remote_function_options
|
|
791
|
+
ensure_full_data!
|
|
792
|
+
@gapi.remote_function_options = new_remote_function_options.to_gapi
|
|
793
|
+
update_gapi!
|
|
794
|
+
end
|
|
795
|
+
|
|
693
796
|
##
|
|
694
797
|
# Updates the routine with changes made in the given block in a single update request. The following attributes
|
|
695
798
|
# may be set: {Updater#routine_type=}, {Updater#language=}, {Updater#arguments=}, {Updater#return_type=},
|
|
@@ -1198,6 +1301,56 @@ module Google
|
|
|
1198
1301
|
@gapi.determinism_level = new_determinism_level
|
|
1199
1302
|
end
|
|
1200
1303
|
|
|
1304
|
+
##
|
|
1305
|
+
# Updates the data governance type of the routine. Optional.
|
|
1306
|
+
#
|
|
1307
|
+
# If set to `DATA_MASKING`, the function is validated and made
|
|
1308
|
+
# available as a masking function. For more information, see [Create custom
|
|
1309
|
+
# masking routines](https://cloud.google.com/bigquery/docs/user-defined-functions#custom-mask).
|
|
1310
|
+
#
|
|
1311
|
+
# @param [String, nil] new_data_governance_type The new data governance type. `nil` to unset.
|
|
1312
|
+
#
|
|
1313
|
+
# @example
|
|
1314
|
+
# require "google/cloud/bigquery"
|
|
1315
|
+
#
|
|
1316
|
+
# bigquery = Google::Cloud::Bigquery.new
|
|
1317
|
+
# dataset = bigquery.dataset "my_dataset"
|
|
1318
|
+
# routine = dataset.routine "my_routine"
|
|
1319
|
+
#
|
|
1320
|
+
# routine.data_governance_type = "DATA_MASKING"
|
|
1321
|
+
#
|
|
1322
|
+
# @!group Attributes
|
|
1323
|
+
#
|
|
1324
|
+
def data_governance_type= new_data_governance_type
|
|
1325
|
+
@gapi.data_governance_type = new_data_governance_type
|
|
1326
|
+
end
|
|
1327
|
+
|
|
1328
|
+
##
|
|
1329
|
+
# Updates the remote function specific options. Optional.
|
|
1330
|
+
#
|
|
1331
|
+
# @param [Google::Cloud::Bigquery::RemoteFunctionOptions] new_remote_function_options The new
|
|
1332
|
+
# remote function options.
|
|
1333
|
+
#
|
|
1334
|
+
# @example
|
|
1335
|
+
# require "google/cloud/bigquery"
|
|
1336
|
+
#
|
|
1337
|
+
# bigquery = Google::Cloud::Bigquery.new
|
|
1338
|
+
# dataset = bigquery.dataset "my_dataset"
|
|
1339
|
+
# routine = dataset.routine "my_routine"
|
|
1340
|
+
#
|
|
1341
|
+
# routine.update do |r|
|
|
1342
|
+
# rfo = Google::Cloud::Bigquery::RemoteFunctionOptions.new
|
|
1343
|
+
# rfo.endpoint = "https://us-east1-my_gcf_project.cloudfunctions.net/remote_add"
|
|
1344
|
+
# rfo.connection = "projects/my-project/locations/us-east1/connections/my-connection"
|
|
1345
|
+
# r.remote_function_options = rfo
|
|
1346
|
+
# end
|
|
1347
|
+
#
|
|
1348
|
+
# @!group Attributes
|
|
1349
|
+
#
|
|
1350
|
+
def remote_function_options= new_remote_function_options
|
|
1351
|
+
@gapi.remote_function_options = new_remote_function_options.to_gapi
|
|
1352
|
+
end
|
|
1353
|
+
|
|
1201
1354
|
def update
|
|
1202
1355
|
raise "not implemented in #{self.class}"
|
|
1203
1356
|
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 }
|
|
@@ -109,29 +109,31 @@ module Google
|
|
|
109
109
|
|
|
110
110
|
##
|
|
111
111
|
# Returns the dataset specified by datasetID.
|
|
112
|
-
def get_dataset dataset_id
|
|
113
|
-
get_project_dataset @project, dataset_id
|
|
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
|
|
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
|
|
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
|
|
|
125
127
|
##
|
|
126
128
|
# Creates a new empty dataset.
|
|
127
|
-
def insert_dataset new_dataset_gapi
|
|
128
|
-
execute { service.insert_dataset @project, new_dataset_gapi }
|
|
129
|
+
def insert_dataset new_dataset_gapi, access_policy_version: nil
|
|
130
|
+
execute { service.insert_dataset @project, new_dataset_gapi, access_policy_version: access_policy_version }
|
|
129
131
|
end
|
|
130
132
|
|
|
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
|
|
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
|
|
@@ -140,7 +142,8 @@ module Google
|
|
|
140
142
|
patch_with_backoff = true
|
|
141
143
|
end
|
|
142
144
|
execute backoff: patch_with_backoff do
|
|
143
|
-
service.patch_dataset @project, dataset_id, patched_dataset_gapi, options: options
|
|
145
|
+
service.patch_dataset @project, dataset_id, patched_dataset_gapi, options: options,
|
|
146
|
+
access_policy_version: access_policy_version, update_mode: update_mode
|
|
144
147
|
end
|
|
145
148
|
end
|
|
146
149
|
|
|
@@ -244,7 +247,8 @@ module Google
|
|
|
244
247
|
|
|
245
248
|
##
|
|
246
249
|
# Retrieves data from the table.
|
|
247
|
-
def list_tabledata dataset_id, table_id, max: nil, token: nil, start: nil
|
|
250
|
+
def list_tabledata dataset_id, table_id, max: nil, token: nil, start: nil,
|
|
251
|
+
format_options_use_int64_timestamp: nil
|
|
248
252
|
# The list operation is considered idempotent
|
|
249
253
|
execute backoff: true do
|
|
250
254
|
json_txt = service.list_table_data \
|
|
@@ -252,7 +256,8 @@ module Google
|
|
|
252
256
|
max_results: max,
|
|
253
257
|
page_token: token,
|
|
254
258
|
start_index: start,
|
|
255
|
-
options: { skip_deserialization: true }
|
|
259
|
+
options: { skip_deserialization: true },
|
|
260
|
+
format_options_use_int64_timestamp: format_options_use_int64_timestamp
|
|
256
261
|
JSON.parse json_txt, symbolize_names: true
|
|
257
262
|
end
|
|
258
263
|
end
|
|
@@ -456,7 +461,8 @@ module Google
|
|
|
456
461
|
|
|
457
462
|
##
|
|
458
463
|
# Returns the query data for the job
|
|
459
|
-
def job_query_results job_id, location: nil, max: nil, token: nil,
|
|
464
|
+
def job_query_results job_id, location: nil, max: nil, token: nil,
|
|
465
|
+
start: nil, timeout: nil, format_options_use_int64_timestamp: nil
|
|
460
466
|
# The get operation is considered idempotent
|
|
461
467
|
execute backoff: true do
|
|
462
468
|
service.get_job_query_results @project, job_id,
|
|
@@ -464,7 +470,8 @@ module Google
|
|
|
464
470
|
max_results: max,
|
|
465
471
|
page_token: token,
|
|
466
472
|
start_index: start,
|
|
467
|
-
timeout_ms: timeout
|
|
473
|
+
timeout_ms: timeout,
|
|
474
|
+
format_options_use_int64_timestamp: format_options_use_int64_timestamp
|
|
468
475
|
end
|
|
469
476
|
end
|
|
470
477
|
|