google-cloud-bigquery 1.40.0 → 1.41.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/lib/google/cloud/bigquery/convert.rb +3 -3
- data/lib/google/cloud/bigquery/copy_job.rb +16 -4
- data/lib/google/cloud/bigquery/dataset.rb +47 -10
- data/lib/google/cloud/bigquery/extract_job.rb +8 -2
- data/lib/google/cloud/bigquery/job.rb +2 -2
- data/lib/google/cloud/bigquery/load_job.rb +8 -2
- data/lib/google/cloud/bigquery/query_job.rb +9 -2
- data/lib/google/cloud/bigquery/service.rb +13 -4
- data/lib/google/cloud/bigquery/table.rb +7 -6
- data/lib/google/cloud/bigquery/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f13891ae7f46f3a0561140fabe4eed4cc426923258e17ed4cc10cc8155f9129
|
4
|
+
data.tar.gz: 65eb5cfc6fb0feadae0d4503bcf2bd1942a0a9740a6f4f1b6f6aaddf7ee244c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cecf4d1450deb04f33772ebc0bf18892816dda84e9e2b43668615dc37c49b3319465c3d0f3cb9c07ca9cc5a5e7a7118daab1f1aa51c25bf83ebadc925bd52eef
|
7
|
+
data.tar.gz: c678e3b5420f82894c1d4935f4f89959fda4ea6e66faffa7fb649c0ff3c0e2fec91daf3e77208e02eb4747cf1a3d41ef5764a4b4da8b76b2a03328861121c7c2
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# Release History
|
2
2
|
|
3
|
+
### 1.41.0 (2023-01-05)
|
4
|
+
|
5
|
+
#### Features
|
6
|
+
|
7
|
+
* Add support for partial projection of table metadata
|
8
|
+
#### Bug Fixes
|
9
|
+
|
10
|
+
* Fix querying of array of structs in named parameters ([#19466](https://github.com/googleapis/google-cloud-ruby/issues/19466))
|
11
|
+
|
3
12
|
### 1.40.0 (2022-12-14)
|
4
13
|
|
5
14
|
#### Features
|
@@ -254,11 +254,11 @@ module Google
|
|
254
254
|
|
255
255
|
##
|
256
256
|
# Lists are specified by providing the type code in an array. For example, an array of integers are specified as
|
257
|
-
# `[:INT64]`. Extracts the symbol.
|
257
|
+
# `[:INT64]`. Extracts the symbol/hash.
|
258
258
|
def self.extract_array_type type
|
259
259
|
return nil if type.nil?
|
260
|
-
unless type.is_a?(Array) && type.count == 1 && type.first.is_a?(Symbol)
|
261
|
-
raise ArgumentError, "types Array #{type.inspect} should include only a single symbol element."
|
260
|
+
unless type.is_a?(Array) && type.count == 1 && (type.first.is_a?(Symbol) || type.first.is_a?(Hash))
|
261
|
+
raise ArgumentError, "types Array #{type.inspect} should include only a single symbol or hash element."
|
262
262
|
end
|
263
263
|
type.first
|
264
264
|
end
|
@@ -64,23 +64,35 @@ module Google
|
|
64
64
|
# The table from which data is copied. This is the table on
|
65
65
|
# which {Table#copy_job} was called.
|
66
66
|
#
|
67
|
+
# @param [String] view Specifies the view that determines which table information is returned.
|
68
|
+
# By default, basic table information and storage statistics (STORAGE_STATS) are returned.
|
69
|
+
# Accepted values include `:unspecified`, `:basic`, `:storage`, and
|
70
|
+
# `:full`. For more information, see [BigQuery Classes](@todo: Update the link).
|
71
|
+
# The default value is the `:unspecified` view type.
|
72
|
+
#
|
67
73
|
# @return [Table] A table instance.
|
68
74
|
#
|
69
|
-
def source
|
75
|
+
def source view: nil
|
70
76
|
table = @gapi.configuration.copy.source_table
|
71
77
|
return nil unless table
|
72
|
-
retrieve_table table.project_id, table.dataset_id, table.table_id
|
78
|
+
retrieve_table table.project_id, table.dataset_id, table.table_id, metadata_view: view
|
73
79
|
end
|
74
80
|
|
75
81
|
##
|
76
82
|
# The table to which data is copied.
|
77
83
|
#
|
84
|
+
# @param [String] view Specifies the view that determines which table information is returned.
|
85
|
+
# By default, basic table information and storage statistics (STORAGE_STATS) are returned.
|
86
|
+
# Accepted values include `:unspecified`, `:basic`, `:storage`, and
|
87
|
+
# `:full`. For more information, see [BigQuery Classes](@todo: Update the link).
|
88
|
+
# The default value is the `:unspecified` view type.
|
89
|
+
#
|
78
90
|
# @return [Table] A table instance.
|
79
91
|
#
|
80
|
-
def destination
|
92
|
+
def destination view: nil
|
81
93
|
table = @gapi.configuration.copy.destination_table
|
82
94
|
return nil unless table
|
83
|
-
retrieve_table table.project_id, table.dataset_id, table.table_id
|
95
|
+
retrieve_table table.project_id, table.dataset_id, table.table_id, metadata_view: view
|
84
96
|
end
|
85
97
|
|
86
98
|
##
|
@@ -793,6 +793,11 @@ module Google
|
|
793
793
|
# object without verifying that the resource exists on the BigQuery
|
794
794
|
# service. Calls made on this object will raise errors if the resource
|
795
795
|
# does not exist. Default is `false`. Optional.
|
796
|
+
# @param [String] view Specifies the view that determines which table information is returned.
|
797
|
+
# By default, basic table information and storage statistics (STORAGE_STATS) are returned.
|
798
|
+
# Accepted values include `:unspecified`, `:basic`, `:storage`, and
|
799
|
+
# `:full`. For more information, see [BigQuery Classes](@todo: Update the link).
|
800
|
+
# The default value is the `:unspecified` view type.
|
796
801
|
#
|
797
802
|
# @return [Google::Cloud::Bigquery::Table, nil] Returns `nil` if the
|
798
803
|
# table does not exist.
|
@@ -815,13 +820,22 @@ module Google
|
|
815
820
|
#
|
816
821
|
# table = dataset.table "my_table", skip_lookup: true
|
817
822
|
#
|
823
|
+
# @example Avoid retrieving transient stats of the table with `view`:
|
824
|
+
# require "google/cloud/bigquery"
|
825
|
+
#
|
826
|
+
# bigquery = Google::Cloud::Bigquery.new
|
827
|
+
#
|
828
|
+
# dataset = bigquery.dataset "my_dataset"
|
829
|
+
#
|
830
|
+
# table = dataset.table "my_table", view: "basic"
|
831
|
+
#
|
818
832
|
# @!group Table
|
819
833
|
#
|
820
|
-
def table table_id, skip_lookup: nil
|
834
|
+
def table table_id, skip_lookup: nil, view: nil
|
821
835
|
ensure_service!
|
822
836
|
return Table.new_reference project_id, dataset_id, table_id, service if skip_lookup
|
823
|
-
gapi = service.get_table dataset_id, table_id
|
824
|
-
Table.from_gapi gapi, service
|
837
|
+
gapi = service.get_table dataset_id, table_id, metadata_view: view
|
838
|
+
Table.from_gapi gapi, service, metadata_view: view
|
825
839
|
rescue Google::Cloud::NotFoundError
|
826
840
|
nil
|
827
841
|
end
|
@@ -2658,6 +2672,11 @@ module Google
|
|
2658
2672
|
# messages before the batch is published. Default is 10.
|
2659
2673
|
# @attr_reader [Numeric] threads The number of threads used to insert
|
2660
2674
|
# batches of rows. Default is 4.
|
2675
|
+
# @param [String] view Specifies the view that determines which table information is returned.
|
2676
|
+
# By default, basic table information and storage statistics (STORAGE_STATS) are returned.
|
2677
|
+
# Accepted values include `:unspecified`, `:basic`, `:storage`, and
|
2678
|
+
# `:full`. For more information, see [BigQuery Classes](@todo: Update the link).
|
2679
|
+
# The default value is the `:unspecified` view type.
|
2661
2680
|
# @yield [response] the callback for when a batch of rows is inserted
|
2662
2681
|
# @yieldparam [Table::AsyncInserter::Result] result the result of the
|
2663
2682
|
# asynchronous insert
|
@@ -2686,13 +2705,35 @@ module Google
|
|
2686
2705
|
#
|
2687
2706
|
# inserter.stop.wait!
|
2688
2707
|
#
|
2708
|
+
# @example Avoid retrieving transient stats of the table with while inserting :
|
2709
|
+
# require "google/cloud/bigquery"
|
2710
|
+
#
|
2711
|
+
# bigquery = Google::Cloud::Bigquery.new
|
2712
|
+
# dataset = bigquery.dataset "my_dataset"
|
2713
|
+
# inserter = dataset.insert_async("my_table", view: "basic") do |result|
|
2714
|
+
# if result.error?
|
2715
|
+
# log_error result.error
|
2716
|
+
# else
|
2717
|
+
# log_insert "inserted #{result.insert_count} rows " \
|
2718
|
+
# "with #{result.error_count} errors"
|
2719
|
+
# end
|
2720
|
+
# end
|
2721
|
+
#
|
2722
|
+
# rows = [
|
2723
|
+
# { "first_name" => "Alice", "age" => 21 },
|
2724
|
+
# { "first_name" => "Bob", "age" => 22 }
|
2725
|
+
# ]
|
2726
|
+
# inserter.insert rows
|
2727
|
+
#
|
2728
|
+
# inserter.stop.wait!
|
2729
|
+
#
|
2689
2730
|
def insert_async table_id, skip_invalid: nil, ignore_unknown: nil, max_bytes: 10_000_000, max_rows: 500,
|
2690
|
-
interval: 10, threads: 4, &block
|
2731
|
+
interval: 10, threads: 4, view: nil, &block
|
2691
2732
|
ensure_service!
|
2692
2733
|
|
2693
2734
|
# Get table, don't use Dataset#table which handles NotFoundError
|
2694
|
-
gapi = service.get_table dataset_id, table_id
|
2695
|
-
table = Table.from_gapi gapi, service
|
2735
|
+
gapi = service.get_table dataset_id, table_id, metadata_view: view
|
2736
|
+
table = Table.from_gapi gapi, service, metadata_view: view
|
2696
2737
|
# Get the AsyncInserter from the table
|
2697
2738
|
table.insert_async skip_invalid: skip_invalid,
|
2698
2739
|
ignore_unknown: ignore_unknown,
|
@@ -2944,8 +2985,6 @@ module Google
|
|
2944
2985
|
@access
|
2945
2986
|
end
|
2946
2987
|
|
2947
|
-
# rubocop:disable Style/MethodDefParentheses
|
2948
|
-
|
2949
2988
|
##
|
2950
2989
|
# @raise [RuntimeError] not implemented
|
2951
2990
|
def delete(*)
|
@@ -3049,8 +3088,6 @@ module Google
|
|
3049
3088
|
end
|
3050
3089
|
alias refresh! reload!
|
3051
3090
|
|
3052
|
-
# rubocop:enable Style/MethodDefParentheses
|
3053
|
-
|
3054
3091
|
##
|
3055
3092
|
# @private Make sure any access changes are saved
|
3056
3093
|
def check_for_mutated_access!
|
@@ -65,11 +65,17 @@ module Google
|
|
65
65
|
##
|
66
66
|
# The table or model which is exported.
|
67
67
|
#
|
68
|
+
# @param [String] view Specifies the view that determines which table information is returned.
|
69
|
+
# By default, basic table information and storage statistics (STORAGE_STATS) are returned.
|
70
|
+
# Accepted values include `:unspecified`, `:basic`, `:storage`, and
|
71
|
+
# `:full`. For more information, see [BigQuery Classes](@todo: Update the link).
|
72
|
+
# The default value is the `:unspecified` view type.
|
73
|
+
#
|
68
74
|
# @return [Table, Model, nil] A table or model instance, or `nil`.
|
69
75
|
#
|
70
|
-
def source
|
76
|
+
def source view: nil
|
71
77
|
if (table = @gapi.configuration.extract.source_table)
|
72
|
-
retrieve_table table.project_id, table.dataset_id, table.table_id
|
78
|
+
retrieve_table table.project_id, table.dataset_id, table.table_id, metadata_view: view
|
73
79
|
elsif (model = @gapi.configuration.extract.source_model)
|
74
80
|
retrieve_model model.project_id, model.dataset_id, model.model_id
|
75
81
|
end
|
@@ -710,9 +710,9 @@ module Google
|
|
710
710
|
raise "Must have active connection" unless service
|
711
711
|
end
|
712
712
|
|
713
|
-
def retrieve_table project_id, dataset_id, table_id
|
713
|
+
def retrieve_table project_id, dataset_id, table_id, metadata_view: nil
|
714
714
|
ensure_service!
|
715
|
-
gapi = service.get_project_table project_id, dataset_id, table_id
|
715
|
+
gapi = service.get_project_table project_id, dataset_id, table_id, metadata_view: metadata_view
|
716
716
|
Table.from_gapi gapi, service
|
717
717
|
rescue Google::Cloud::NotFoundError
|
718
718
|
nil
|
@@ -62,12 +62,18 @@ module Google
|
|
62
62
|
# The table into which the operation loads data. This is the table on
|
63
63
|
# which {Table#load_job} was invoked.
|
64
64
|
#
|
65
|
+
# @param [String] view Specifies the view that determines which table information is returned.
|
66
|
+
# By default, basic table information and storage statistics (STORAGE_STATS) are returned.
|
67
|
+
# Accepted values include `:unspecified`, `:basic`, `:storage`, and
|
68
|
+
# `:full`. For more information, see [BigQuery Classes](@todo: Update the link).
|
69
|
+
# The default value is the `:unspecified` view type.
|
70
|
+
#
|
65
71
|
# @return [Table] A table instance.
|
66
72
|
#
|
67
|
-
def destination
|
73
|
+
def destination view: nil
|
68
74
|
table = @gapi.configuration.load.destination_table
|
69
75
|
return nil unless table
|
70
|
-
retrieve_table table.project_id, table.dataset_id, table.table_id
|
76
|
+
retrieve_table table.project_id, table.dataset_id, table.table_id, metadata_view: view
|
71
77
|
end
|
72
78
|
|
73
79
|
##
|
@@ -437,14 +437,21 @@ module Google
|
|
437
437
|
##
|
438
438
|
# The table in which the query results are stored.
|
439
439
|
#
|
440
|
+
# @param [String] view Specifies the view that determines which table information is returned.
|
441
|
+
# By default, basic table information and storage statistics (STORAGE_STATS) are returned.
|
442
|
+
# Accepted values include `:unspecified`, `:basic`, `:storage`, and
|
443
|
+
# `:full`. For more information, see [BigQuery Classes](@todo: Update the link).
|
444
|
+
# The default value is the `:unspecified` view type.
|
445
|
+
#
|
440
446
|
# @return [Table] A table instance.
|
441
447
|
#
|
442
|
-
def destination
|
448
|
+
def destination view: nil
|
443
449
|
table = @gapi.configuration.query.destination_table
|
444
450
|
return nil unless table
|
445
451
|
retrieve_table table.project_id,
|
446
452
|
table.dataset_id,
|
447
|
-
table.table_id
|
453
|
+
table.table_id,
|
454
|
+
metadata_view: view
|
448
455
|
end
|
449
456
|
|
450
457
|
##
|
@@ -144,10 +144,11 @@ module Google
|
|
144
144
|
|
145
145
|
##
|
146
146
|
# Gets the specified table resource by full table reference.
|
147
|
-
def get_project_table project_id, dataset_id, table_id
|
147
|
+
def get_project_table project_id, dataset_id, table_id, metadata_view: nil
|
148
|
+
metadata_view = table_metadata_view_type_for metadata_view
|
148
149
|
# The get operation is considered idempotent
|
149
150
|
execute backoff: true do
|
150
|
-
service.get_table project_id, dataset_id, table_id
|
151
|
+
service.get_table project_id, dataset_id, table_id, view: metadata_view
|
151
152
|
end
|
152
153
|
end
|
153
154
|
|
@@ -156,8 +157,8 @@ module Google
|
|
156
157
|
# This method does not return the data in the table,
|
157
158
|
# it only returns the table resource,
|
158
159
|
# which describes the structure of this table.
|
159
|
-
def get_table dataset_id, table_id
|
160
|
-
get_project_table @project, dataset_id, table_id
|
160
|
+
def get_table dataset_id, table_id, metadata_view: nil
|
161
|
+
get_project_table @project, dataset_id, table_id, metadata_view: metadata_view
|
161
162
|
end
|
162
163
|
|
163
164
|
##
|
@@ -572,6 +573,14 @@ module Google
|
|
572
573
|
raise Google::Cloud::Error.from_error e
|
573
574
|
end
|
574
575
|
|
576
|
+
def table_metadata_view_type_for str
|
577
|
+
return nil if str.nil?
|
578
|
+
{ "unspecified" => "TABLE_METADATA_VIEW_UNSPECIFIED",
|
579
|
+
"basic" => "BASIC",
|
580
|
+
"storage" => "STORAGE_STATS",
|
581
|
+
"full" => "FULL" }[str.to_s.downcase]
|
582
|
+
end
|
583
|
+
|
575
584
|
class Backoff
|
576
585
|
class << self
|
577
586
|
attr_accessor :retries
|
@@ -108,6 +108,10 @@ module Google
|
|
108
108
|
# @private A Google API Client Table Reference object.
|
109
109
|
attr_reader :reference
|
110
110
|
|
111
|
+
##
|
112
|
+
# @private The metadata view type string.
|
113
|
+
attr_accessor :metadata_view
|
114
|
+
|
111
115
|
##
|
112
116
|
# @private Create an empty Table object.
|
113
117
|
def initialize
|
@@ -2836,7 +2840,7 @@ module Google
|
|
2836
2840
|
#
|
2837
2841
|
def reload!
|
2838
2842
|
ensure_service!
|
2839
|
-
@gapi = service.get_table dataset_id, table_id
|
2843
|
+
@gapi = service.get_table dataset_id, table_id, metadata_view: metadata_view
|
2840
2844
|
@reference = nil
|
2841
2845
|
@exists = nil
|
2842
2846
|
self
|
@@ -2970,10 +2974,11 @@ module Google
|
|
2970
2974
|
|
2971
2975
|
##
|
2972
2976
|
# @private New Table from a Google API Client object.
|
2973
|
-
def self.from_gapi gapi, service
|
2977
|
+
def self.from_gapi gapi, service, metadata_view: nil
|
2974
2978
|
new.tap do |f|
|
2975
2979
|
f.gapi = gapi
|
2976
2980
|
f.service = service
|
2981
|
+
f.metadata_view = metadata_view
|
2977
2982
|
end
|
2978
2983
|
end
|
2979
2984
|
|
@@ -3982,8 +3987,6 @@ module Google
|
|
3982
3987
|
schema.record name, description: description, mode: mode, &block
|
3983
3988
|
end
|
3984
3989
|
|
3985
|
-
# rubocop:disable Style/MethodDefParentheses
|
3986
|
-
|
3987
3990
|
##
|
3988
3991
|
# @raise [RuntimeError] not implemented
|
3989
3992
|
def data(*)
|
@@ -4069,8 +4072,6 @@ module Google
|
|
4069
4072
|
end
|
4070
4073
|
alias refresh! reload!
|
4071
4074
|
|
4072
|
-
# rubocop:enable Style/MethodDefParentheses
|
4073
|
-
|
4074
4075
|
##
|
4075
4076
|
# @private Make sure any access changes are saved
|
4076
4077
|
def check_for_mutated_schema!
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-cloud-bigquery
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.41.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Moore
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2023-01-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: concurrent-ruby
|