google-cloud-bigquery 1.14.0 → 1.42.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/AUTHENTICATION.md +17 -54
  3. data/CHANGELOG.md +377 -0
  4. data/CONTRIBUTING.md +328 -116
  5. data/LOGGING.md +1 -1
  6. data/OVERVIEW.md +21 -20
  7. data/TROUBLESHOOTING.md +2 -8
  8. data/lib/google/cloud/bigquery/argument.rb +197 -0
  9. data/lib/google/cloud/bigquery/convert.rb +155 -173
  10. data/lib/google/cloud/bigquery/copy_job.rb +74 -26
  11. data/lib/google/cloud/bigquery/credentials.rb +5 -12
  12. data/lib/google/cloud/bigquery/data.rb +109 -18
  13. data/lib/google/cloud/bigquery/dataset/access.rb +474 -52
  14. data/lib/google/cloud/bigquery/dataset/list.rb +7 -13
  15. data/lib/google/cloud/bigquery/dataset/tag.rb +67 -0
  16. data/lib/google/cloud/bigquery/dataset.rb +1044 -287
  17. data/lib/google/cloud/bigquery/external/avro_source.rb +107 -0
  18. data/lib/google/cloud/bigquery/external/bigtable_source/column.rb +404 -0
  19. data/lib/google/cloud/bigquery/external/bigtable_source/column_family.rb +945 -0
  20. data/lib/google/cloud/bigquery/external/bigtable_source.rb +230 -0
  21. data/lib/google/cloud/bigquery/external/csv_source.rb +481 -0
  22. data/lib/google/cloud/bigquery/external/data_source.rb +771 -0
  23. data/lib/google/cloud/bigquery/external/json_source.rb +170 -0
  24. data/lib/google/cloud/bigquery/external/parquet_source.rb +148 -0
  25. data/lib/google/cloud/bigquery/external/sheets_source.rb +166 -0
  26. data/lib/google/cloud/bigquery/external.rb +50 -2256
  27. data/lib/google/cloud/bigquery/extract_job.rb +226 -61
  28. data/lib/google/cloud/bigquery/insert_response.rb +1 -3
  29. data/lib/google/cloud/bigquery/job/list.rb +10 -14
  30. data/lib/google/cloud/bigquery/job.rb +289 -14
  31. data/lib/google/cloud/bigquery/load_job.rb +810 -136
  32. data/lib/google/cloud/bigquery/model/list.rb +5 -9
  33. data/lib/google/cloud/bigquery/model.rb +247 -16
  34. data/lib/google/cloud/bigquery/policy.rb +432 -0
  35. data/lib/google/cloud/bigquery/project/list.rb +6 -11
  36. data/lib/google/cloud/bigquery/project.rb +509 -250
  37. data/lib/google/cloud/bigquery/query_job.rb +594 -128
  38. data/lib/google/cloud/bigquery/routine/list.rb +165 -0
  39. data/lib/google/cloud/bigquery/routine.rb +1227 -0
  40. data/lib/google/cloud/bigquery/schema/field.rb +413 -63
  41. data/lib/google/cloud/bigquery/schema.rb +221 -48
  42. data/lib/google/cloud/bigquery/service.rb +204 -112
  43. data/lib/google/cloud/bigquery/standard_sql.rb +269 -53
  44. data/lib/google/cloud/bigquery/table/async_inserter.rb +86 -43
  45. data/lib/google/cloud/bigquery/table/list.rb +6 -11
  46. data/lib/google/cloud/bigquery/table.rb +1470 -377
  47. data/lib/google/cloud/bigquery/time.rb +6 -0
  48. data/lib/google/cloud/bigquery/version.rb +1 -1
  49. data/lib/google/cloud/bigquery.rb +4 -6
  50. data/lib/google-cloud-bigquery.rb +14 -13
  51. metadata +66 -38
@@ -71,8 +71,7 @@ module Google
71
71
  def next
72
72
  return nil unless next?
73
73
  ensure_service!
74
- options = { all: @hidden, filter: @filter, token: token, max: @max }
75
- gapi = @service.list_datasets options
74
+ gapi = @service.list_datasets all: @hidden, filter: @filter, token: token, max: @max
76
75
  self.class.from_gapi gapi, @service, @hidden, @filter, @max
77
76
  end
78
77
 
@@ -121,17 +120,15 @@ module Google
121
120
  # puts dataset.name
122
121
  # end
123
122
  #
124
- def all request_limit: nil
123
+ def all request_limit: nil, &block
125
124
  request_limit = request_limit.to_i if request_limit
126
- unless block_given?
127
- return enum_for :all, request_limit: request_limit
128
- end
125
+ return enum_for :all, request_limit: request_limit unless block_given?
129
126
  results = self
130
127
  loop do
131
- results.each { |r| yield r }
128
+ results.each(&block)
132
129
  if request_limit
133
130
  request_limit -= 1
134
- break if request_limit < 0
131
+ break if request_limit.negative?
135
132
  end
136
133
  break unless results.next?
137
134
  results = results.next
@@ -140,11 +137,8 @@ module Google
140
137
 
141
138
  ##
142
139
  # @private New Dataset::List from a response object.
143
- def self.from_gapi gapi_list, service, hidden = nil, filter = nil,
144
- max = nil
145
- datasets = List.new(Array(gapi_list.datasets).map do |gapi_object|
146
- Dataset.from_gapi gapi_object, service
147
- end)
140
+ def self.from_gapi gapi_list, service, hidden = nil, filter = nil, max = nil
141
+ datasets = List.new(Array(gapi_list.datasets).map { |gapi_object| Dataset.from_gapi gapi_object, service })
148
142
  datasets.instance_variable_set :@token, gapi_list.next_page_token
149
143
  datasets.instance_variable_set :@etag, gapi_list.etag
150
144
  datasets.instance_variable_set :@service, service
@@ -0,0 +1,67 @@
1
+ # Copyright 2022 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
+ require "google/apis/bigquery_v2"
16
+
17
+ module Google
18
+ module Cloud
19
+ module Bigquery
20
+ class Dataset
21
+ ##
22
+ # A global tag managed by Resource Manager.
23
+ #
24
+ # @see https://cloud.google.com/iam/docs/tags-access-control#definitions
25
+ #
26
+ class Tag
27
+ ##
28
+ # @private The Google API Client object.
29
+ attr_accessor :gapi
30
+
31
+ ##
32
+ # @private Create an empty Tag object.
33
+ def initialize
34
+ @gapi = Google::Apis::BigqueryV2::Dataset::Tag.new
35
+ end
36
+
37
+ ##
38
+ # The namespaced friendly name of the tag key, e.g. "12345/environment" where
39
+ # 12345 is org id.
40
+ #
41
+ # @return [String]
42
+ #
43
+ def tag_key
44
+ @gapi.tag_key
45
+ end
46
+
47
+ ##
48
+ # The friendly short name of the tag value, e.g. "production".
49
+ #
50
+ # @return [String]
51
+ #
52
+ def tag_value
53
+ @gapi.tag_value
54
+ end
55
+
56
+ ##
57
+ # @private Google API Client object.
58
+ def self.from_gapi gapi
59
+ new_tag = new
60
+ new_tag.instance_variable_set :@gapi, gapi
61
+ new_tag
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end