google-cloud-bigquery 1.14.0 → 1.42.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/AUTHENTICATION.md +17 -54
- data/CHANGELOG.md +377 -0
- data/CONTRIBUTING.md +328 -116
- data/LOGGING.md +1 -1
- data/OVERVIEW.md +21 -20
- data/TROUBLESHOOTING.md +2 -8
- data/lib/google/cloud/bigquery/argument.rb +197 -0
- data/lib/google/cloud/bigquery/convert.rb +155 -173
- data/lib/google/cloud/bigquery/copy_job.rb +74 -26
- data/lib/google/cloud/bigquery/credentials.rb +5 -12
- data/lib/google/cloud/bigquery/data.rb +109 -18
- data/lib/google/cloud/bigquery/dataset/access.rb +474 -52
- data/lib/google/cloud/bigquery/dataset/list.rb +7 -13
- data/lib/google/cloud/bigquery/dataset/tag.rb +67 -0
- data/lib/google/cloud/bigquery/dataset.rb +1044 -287
- data/lib/google/cloud/bigquery/external/avro_source.rb +107 -0
- data/lib/google/cloud/bigquery/external/bigtable_source/column.rb +404 -0
- data/lib/google/cloud/bigquery/external/bigtable_source/column_family.rb +945 -0
- data/lib/google/cloud/bigquery/external/bigtable_source.rb +230 -0
- data/lib/google/cloud/bigquery/external/csv_source.rb +481 -0
- data/lib/google/cloud/bigquery/external/data_source.rb +771 -0
- data/lib/google/cloud/bigquery/external/json_source.rb +170 -0
- data/lib/google/cloud/bigquery/external/parquet_source.rb +148 -0
- data/lib/google/cloud/bigquery/external/sheets_source.rb +166 -0
- data/lib/google/cloud/bigquery/external.rb +50 -2256
- data/lib/google/cloud/bigquery/extract_job.rb +226 -61
- data/lib/google/cloud/bigquery/insert_response.rb +1 -3
- data/lib/google/cloud/bigquery/job/list.rb +10 -14
- data/lib/google/cloud/bigquery/job.rb +289 -14
- data/lib/google/cloud/bigquery/load_job.rb +810 -136
- data/lib/google/cloud/bigquery/model/list.rb +5 -9
- data/lib/google/cloud/bigquery/model.rb +247 -16
- data/lib/google/cloud/bigquery/policy.rb +432 -0
- data/lib/google/cloud/bigquery/project/list.rb +6 -11
- data/lib/google/cloud/bigquery/project.rb +509 -250
- data/lib/google/cloud/bigquery/query_job.rb +594 -128
- data/lib/google/cloud/bigquery/routine/list.rb +165 -0
- data/lib/google/cloud/bigquery/routine.rb +1227 -0
- data/lib/google/cloud/bigquery/schema/field.rb +413 -63
- data/lib/google/cloud/bigquery/schema.rb +221 -48
- data/lib/google/cloud/bigquery/service.rb +204 -112
- data/lib/google/cloud/bigquery/standard_sql.rb +269 -53
- data/lib/google/cloud/bigquery/table/async_inserter.rb +86 -43
- data/lib/google/cloud/bigquery/table/list.rb +6 -11
- data/lib/google/cloud/bigquery/table.rb +1470 -377
- data/lib/google/cloud/bigquery/time.rb +6 -0
- data/lib/google/cloud/bigquery/version.rb +1 -1
- data/lib/google/cloud/bigquery.rb +4 -6
- data/lib/google-cloud-bigquery.rb +14 -13
- metadata +66 -38
@@ -0,0 +1,107 @@
|
|
1
|
+
# Copyright 2021 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
|
+
|
16
|
+
require "google/apis/bigquery_v2"
|
17
|
+
|
18
|
+
module Google
|
19
|
+
module Cloud
|
20
|
+
module Bigquery
|
21
|
+
module External
|
22
|
+
##
|
23
|
+
# # AvroSource
|
24
|
+
#
|
25
|
+
# {External::AvroSource} is a subclass of {External::DataSource} and
|
26
|
+
# represents a Avro external data source that can be queried
|
27
|
+
# from directly, even though the data is not stored in BigQuery. Instead
|
28
|
+
# of loading or streaming the data, this object references the external
|
29
|
+
# data source.
|
30
|
+
#
|
31
|
+
# @example
|
32
|
+
# require "google/cloud/bigquery"
|
33
|
+
#
|
34
|
+
# bigquery = Google::Cloud::Bigquery.new
|
35
|
+
#
|
36
|
+
# avro_url = "gs://bucket/path/to/*.avro"
|
37
|
+
# avro_table = bigquery.external avro_url do |avro|
|
38
|
+
# avro.use_avro_logical_types = 1
|
39
|
+
# end
|
40
|
+
#
|
41
|
+
# data = bigquery.query "SELECT * FROM my_ext_table",
|
42
|
+
# external: { my_ext_table: avro_table }
|
43
|
+
#
|
44
|
+
# # Iterate over the first page of results
|
45
|
+
# data.each do |row|
|
46
|
+
# puts row[:name]
|
47
|
+
# end
|
48
|
+
# # Retrieve the next page of results
|
49
|
+
# data = data.next if data.next?
|
50
|
+
#
|
51
|
+
class AvroSource < External::DataSource
|
52
|
+
##
|
53
|
+
# @private Create an empty AvroSource object.
|
54
|
+
def initialize
|
55
|
+
super
|
56
|
+
@gapi.avro_options = Google::Apis::BigqueryV2::AvroOptions.new
|
57
|
+
end
|
58
|
+
|
59
|
+
##
|
60
|
+
# Indicates whether to interpret logical types as the corresponding BigQuery data type (for example,
|
61
|
+
# `TIMESTAMP`), instead of using the raw type (for example, `INTEGER`).
|
62
|
+
#
|
63
|
+
# @return [Boolean]
|
64
|
+
#
|
65
|
+
# @example
|
66
|
+
# require "google/cloud/bigquery"
|
67
|
+
#
|
68
|
+
# bigquery = Google::Cloud::Bigquery.new
|
69
|
+
#
|
70
|
+
# avro_url = "gs://bucket/path/to/*.avro"
|
71
|
+
# avro_table = bigquery.external avro_url do |avro|
|
72
|
+
# avro.use_avro_logical_types = true
|
73
|
+
# end
|
74
|
+
#
|
75
|
+
# avro_table.use_avro_logical_types #=> true
|
76
|
+
#
|
77
|
+
def use_avro_logical_types
|
78
|
+
@gapi.avro_options.use_avro_logical_types
|
79
|
+
end
|
80
|
+
|
81
|
+
##
|
82
|
+
# Sets whether to interpret logical types as the corresponding BigQuery data type (for example, `TIMESTAMP`),
|
83
|
+
# instead of using the raw type (for example, `INTEGER`).
|
84
|
+
#
|
85
|
+
# @param [Boolean] new_use_avro_logical_types The new `use_avro_logical_types` value.
|
86
|
+
#
|
87
|
+
# @example
|
88
|
+
# require "google/cloud/bigquery"
|
89
|
+
#
|
90
|
+
# bigquery = Google::Cloud::Bigquery.new
|
91
|
+
#
|
92
|
+
# avro_url = "gs://bucket/path/to/*.avro"
|
93
|
+
# avro_table = bigquery.external avro_url do |avro|
|
94
|
+
# avro.use_avro_logical_types = true
|
95
|
+
# end
|
96
|
+
#
|
97
|
+
# avro_table.use_avro_logical_types #=> true
|
98
|
+
#
|
99
|
+
def use_avro_logical_types= new_use_avro_logical_types
|
100
|
+
frozen_check!
|
101
|
+
@gapi.avro_options.use_avro_logical_types = new_use_avro_logical_types
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
@@ -0,0 +1,404 @@
|
|
1
|
+
# Copyright 2021 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
|
+
|
16
|
+
require "google/apis/bigquery_v2"
|
17
|
+
require "base64"
|
18
|
+
|
19
|
+
module Google
|
20
|
+
module Cloud
|
21
|
+
module Bigquery
|
22
|
+
module External
|
23
|
+
class BigtableSource < External::DataSource
|
24
|
+
##
|
25
|
+
# # BigtableSource::Column
|
26
|
+
#
|
27
|
+
# A Bigtable column to expose in the table schema along with its
|
28
|
+
# types.
|
29
|
+
#
|
30
|
+
# @example
|
31
|
+
# require "google/cloud/bigquery"
|
32
|
+
#
|
33
|
+
# bigquery = Google::Cloud::Bigquery.new
|
34
|
+
#
|
35
|
+
# bigtable_url = "https://googleapis.com/bigtable/projects/..."
|
36
|
+
# bigtable_table = bigquery.external bigtable_url do |bt|
|
37
|
+
# bt.rowkey_as_string = true
|
38
|
+
# bt.add_family "user" do |u|
|
39
|
+
# u.add_string "name"
|
40
|
+
# u.add_string "email"
|
41
|
+
# u.add_integer "age"
|
42
|
+
# u.add_boolean "active"
|
43
|
+
# end
|
44
|
+
# end
|
45
|
+
#
|
46
|
+
# data = bigquery.query "SELECT * FROM my_ext_table",
|
47
|
+
# external: { my_ext_table: bigtable_table }
|
48
|
+
#
|
49
|
+
# # Iterate over the first page of results
|
50
|
+
# data.each do |row|
|
51
|
+
# puts row[:name]
|
52
|
+
# end
|
53
|
+
# # Retrieve the next page of results
|
54
|
+
# data = data.next if data.next?
|
55
|
+
#
|
56
|
+
class Column
|
57
|
+
##
|
58
|
+
# @private Create an empty BigtableSource::Column object.
|
59
|
+
def initialize
|
60
|
+
@gapi = Google::Apis::BigqueryV2::BigtableColumn.new
|
61
|
+
end
|
62
|
+
|
63
|
+
##
|
64
|
+
# Qualifier of the column. Columns in the parent column family that
|
65
|
+
# has this exact qualifier are exposed as `.` field. If the
|
66
|
+
# qualifier is valid UTF-8 string, it will be represented as a UTF-8
|
67
|
+
# string. Otherwise, it will represented as a ASCII-8BIT string.
|
68
|
+
#
|
69
|
+
# If the qualifier is not a valid BigQuery field identifier (does
|
70
|
+
# not match `[a-zA-Z][a-zA-Z0-9_]*`) a valid identifier must be
|
71
|
+
# provided as `field_name`.
|
72
|
+
#
|
73
|
+
# @return [String]
|
74
|
+
#
|
75
|
+
# @example
|
76
|
+
# require "google/cloud/bigquery"
|
77
|
+
#
|
78
|
+
# bigquery = Google::Cloud::Bigquery.new
|
79
|
+
#
|
80
|
+
# bigtable_url = "https://googleapis.com/bigtable/projects/..."
|
81
|
+
# bigtable_table = bigquery.external bigtable_url do |bt|
|
82
|
+
# bt.add_family "user" do |u|
|
83
|
+
# u.add_string "name" do |col|
|
84
|
+
# col.qualifier # "user"
|
85
|
+
# col.qualifier = "User"
|
86
|
+
# col.qualifier # "User"
|
87
|
+
# end
|
88
|
+
# end
|
89
|
+
# end
|
90
|
+
#
|
91
|
+
def qualifier
|
92
|
+
@gapi.qualifier_string || Base64.strict_decode64(@gapi.qualifier_encoded.to_s)
|
93
|
+
end
|
94
|
+
|
95
|
+
##
|
96
|
+
# Set the qualifier of the column. Columns in the parent column
|
97
|
+
# family that has this exact qualifier are exposed as `.` field.
|
98
|
+
# Values that are valid UTF-8 strings will be treated as such. All
|
99
|
+
# other values will be treated as `BINARY`.
|
100
|
+
#
|
101
|
+
# @param [String] new_qualifier New qualifier value
|
102
|
+
#
|
103
|
+
# @example
|
104
|
+
# require "google/cloud/bigquery"
|
105
|
+
#
|
106
|
+
# bigquery = Google::Cloud::Bigquery.new
|
107
|
+
#
|
108
|
+
# bigtable_url = "https://googleapis.com/bigtable/projects/..."
|
109
|
+
# bigtable_table = bigquery.external bigtable_url do |bt|
|
110
|
+
# bt.add_family "user" do |u|
|
111
|
+
# u.add_string "name" do |col|
|
112
|
+
# col.qualifier # "user"
|
113
|
+
# col.qualifier = "User"
|
114
|
+
# col.qualifier # "User"
|
115
|
+
# end
|
116
|
+
# end
|
117
|
+
# end
|
118
|
+
#
|
119
|
+
def qualifier= new_qualifier
|
120
|
+
frozen_check!
|
121
|
+
raise ArgumentError if new_qualifier.nil?
|
122
|
+
|
123
|
+
utf8_qualifier = new_qualifier.encode Encoding::UTF_8
|
124
|
+
if utf8_qualifier.valid_encoding?
|
125
|
+
@gapi.qualifier_string = utf8_qualifier
|
126
|
+
if @gapi.instance_variables.include? :@qualifier_encoded
|
127
|
+
@gapi.remove_instance_variable :@qualifier_encoded
|
128
|
+
end
|
129
|
+
else
|
130
|
+
@gapi.qualifier_encoded = Base64.strict_encode64 new_qualifier
|
131
|
+
if @gapi.instance_variables.include? :@qualifier_string
|
132
|
+
@gapi.remove_instance_variable :@qualifier_string
|
133
|
+
end
|
134
|
+
end
|
135
|
+
rescue EncodingError
|
136
|
+
@gapi.qualifier_encoded = Base64.strict_encode64 new_qualifier
|
137
|
+
@gapi.remove_instance_variable :@qualifier_string if @gapi.instance_variables.include? :@qualifier_string
|
138
|
+
end
|
139
|
+
|
140
|
+
##
|
141
|
+
# The encoding of the values when the type is not `STRING`.
|
142
|
+
#
|
143
|
+
# @return [String]
|
144
|
+
#
|
145
|
+
# @example
|
146
|
+
# require "google/cloud/bigquery"
|
147
|
+
#
|
148
|
+
# bigquery = Google::Cloud::Bigquery.new
|
149
|
+
#
|
150
|
+
# bigtable_url = "https://googleapis.com/bigtable/projects/..."
|
151
|
+
# bigtable_table = bigquery.external bigtable_url do |bt|
|
152
|
+
# bt.add_family "user" do |u|
|
153
|
+
# u.add_bytes "name" do |col|
|
154
|
+
# col.encoding = "TEXT"
|
155
|
+
# col.encoding # "TEXT"
|
156
|
+
# end
|
157
|
+
# end
|
158
|
+
# end
|
159
|
+
#
|
160
|
+
def encoding
|
161
|
+
@gapi.encoding
|
162
|
+
end
|
163
|
+
|
164
|
+
##
|
165
|
+
# Set the encoding of the values when the type is not `STRING`.
|
166
|
+
# Acceptable encoding values are:
|
167
|
+
#
|
168
|
+
# * `TEXT` - indicates values are alphanumeric text strings.
|
169
|
+
# * `BINARY` - indicates values are encoded using HBase
|
170
|
+
# `Bytes.toBytes` family of functions. This can be overridden on a
|
171
|
+
# column.
|
172
|
+
#
|
173
|
+
# @param [String] new_encoding New encoding value
|
174
|
+
#
|
175
|
+
# @example
|
176
|
+
# require "google/cloud/bigquery"
|
177
|
+
#
|
178
|
+
# bigquery = Google::Cloud::Bigquery.new
|
179
|
+
#
|
180
|
+
# bigtable_url = "https://googleapis.com/bigtable/projects/..."
|
181
|
+
# bigtable_table = bigquery.external bigtable_url do |bt|
|
182
|
+
# bt.add_family "user" do |u|
|
183
|
+
# u.add_bytes "name" do |col|
|
184
|
+
# col.encoding = "TEXT"
|
185
|
+
# col.encoding # "TEXT"
|
186
|
+
# end
|
187
|
+
# end
|
188
|
+
# end
|
189
|
+
#
|
190
|
+
def encoding= new_encoding
|
191
|
+
frozen_check!
|
192
|
+
@gapi.encoding = new_encoding
|
193
|
+
end
|
194
|
+
|
195
|
+
##
|
196
|
+
# If the qualifier is not a valid BigQuery field identifier (does
|
197
|
+
# not match `[a-zA-Z][a-zA-Z0-9_]*`) a valid identifier must be
|
198
|
+
# provided as the column field name and is used as field name in
|
199
|
+
# queries.
|
200
|
+
#
|
201
|
+
# @return [String]
|
202
|
+
#
|
203
|
+
# @example
|
204
|
+
# require "google/cloud/bigquery"
|
205
|
+
#
|
206
|
+
# bigquery = Google::Cloud::Bigquery.new
|
207
|
+
#
|
208
|
+
# bigtable_url = "https://googleapis.com/bigtable/projects/..."
|
209
|
+
# bigtable_table = bigquery.external bigtable_url do |bt|
|
210
|
+
# bt.add_family "user" do |u|
|
211
|
+
# u.add_string "001_name", as: "user" do |col|
|
212
|
+
# col.field_name # "user"
|
213
|
+
# col.field_name = "User"
|
214
|
+
# col.field_name # "User"
|
215
|
+
# end
|
216
|
+
# end
|
217
|
+
# end
|
218
|
+
#
|
219
|
+
def field_name
|
220
|
+
@gapi.field_name
|
221
|
+
end
|
222
|
+
|
223
|
+
##
|
224
|
+
# Sets the identifier to be used as the column field name in queries
|
225
|
+
# when the qualifier is not a valid BigQuery field identifier (does
|
226
|
+
# not match `[a-zA-Z][a-zA-Z0-9_]*`).
|
227
|
+
#
|
228
|
+
# @param [String] new_field_name New field_name value
|
229
|
+
#
|
230
|
+
# @example
|
231
|
+
# require "google/cloud/bigquery"
|
232
|
+
#
|
233
|
+
# bigquery = Google::Cloud::Bigquery.new
|
234
|
+
#
|
235
|
+
# bigtable_url = "https://googleapis.com/bigtable/projects/..."
|
236
|
+
# bigtable_table = bigquery.external bigtable_url do |bt|
|
237
|
+
# bt.add_family "user" do |u|
|
238
|
+
# u.add_string "001_name", as: "user" do |col|
|
239
|
+
# col.field_name # "user"
|
240
|
+
# col.field_name = "User"
|
241
|
+
# col.field_name # "User"
|
242
|
+
# end
|
243
|
+
# end
|
244
|
+
# end
|
245
|
+
#
|
246
|
+
def field_name= new_field_name
|
247
|
+
frozen_check!
|
248
|
+
@gapi.field_name = new_field_name
|
249
|
+
end
|
250
|
+
|
251
|
+
##
|
252
|
+
# Whether only the latest version of value in this column are
|
253
|
+
# exposed. Can also be set at the column family level. However, this
|
254
|
+
# value takes precedence when set at both levels.
|
255
|
+
#
|
256
|
+
# @return [Boolean]
|
257
|
+
#
|
258
|
+
# @example
|
259
|
+
# require "google/cloud/bigquery"
|
260
|
+
#
|
261
|
+
# bigquery = Google::Cloud::Bigquery.new
|
262
|
+
#
|
263
|
+
# bigtable_url = "https://googleapis.com/bigtable/projects/..."
|
264
|
+
# bigtable_table = bigquery.external bigtable_url do |bt|
|
265
|
+
# bt.add_family "user" do |u|
|
266
|
+
# u.add_string "name" do |col|
|
267
|
+
# col.latest = true
|
268
|
+
# col.latest # true
|
269
|
+
# end
|
270
|
+
# end
|
271
|
+
# end
|
272
|
+
#
|
273
|
+
def latest
|
274
|
+
@gapi.only_read_latest
|
275
|
+
end
|
276
|
+
|
277
|
+
##
|
278
|
+
# Set whether only the latest version of value in this column are
|
279
|
+
# exposed. Can also be set at the column family level. However, this
|
280
|
+
# value takes precedence when set at both levels.
|
281
|
+
#
|
282
|
+
# @param [Boolean] new_latest New latest value
|
283
|
+
#
|
284
|
+
# @example
|
285
|
+
# require "google/cloud/bigquery"
|
286
|
+
#
|
287
|
+
# bigquery = Google::Cloud::Bigquery.new
|
288
|
+
#
|
289
|
+
# bigtable_url = "https://googleapis.com/bigtable/projects/..."
|
290
|
+
# bigtable_table = bigquery.external bigtable_url do |bt|
|
291
|
+
# bt.add_family "user" do |u|
|
292
|
+
# u.add_string "name" do |col|
|
293
|
+
# col.latest = true
|
294
|
+
# col.latest # true
|
295
|
+
# end
|
296
|
+
# end
|
297
|
+
# end
|
298
|
+
#
|
299
|
+
def latest= new_latest
|
300
|
+
frozen_check!
|
301
|
+
@gapi.only_read_latest = new_latest
|
302
|
+
end
|
303
|
+
|
304
|
+
##
|
305
|
+
# The type to convert the value in cells of this column. The values
|
306
|
+
# are expected to be encoded using HBase `Bytes.toBytes` function
|
307
|
+
# when using the `BINARY` encoding value. The following BigQuery
|
308
|
+
# types are allowed:
|
309
|
+
#
|
310
|
+
# * `BYTES`
|
311
|
+
# * `STRING`
|
312
|
+
# * `INTEGER`
|
313
|
+
# * `FLOAT`
|
314
|
+
# * `BOOLEAN`
|
315
|
+
#
|
316
|
+
# Default type is `BYTES`. Can also be set at the column family
|
317
|
+
# level. However, this value takes precedence when set at both
|
318
|
+
# levels.
|
319
|
+
#
|
320
|
+
# @return [String]
|
321
|
+
#
|
322
|
+
# @example
|
323
|
+
# require "google/cloud/bigquery"
|
324
|
+
#
|
325
|
+
# bigquery = Google::Cloud::Bigquery.new
|
326
|
+
#
|
327
|
+
# bigtable_url = "https://googleapis.com/bigtable/projects/..."
|
328
|
+
# bigtable_table = bigquery.external bigtable_url do |bt|
|
329
|
+
# bt.add_family "user" do |u|
|
330
|
+
# u.add_string "name" do |col|
|
331
|
+
# col.type # "STRING"
|
332
|
+
# end
|
333
|
+
# end
|
334
|
+
# end
|
335
|
+
#
|
336
|
+
def type
|
337
|
+
@gapi.type
|
338
|
+
end
|
339
|
+
|
340
|
+
##
|
341
|
+
# Set the type to convert the value in cells of this column. The
|
342
|
+
# values are expected to be encoded using HBase `Bytes.toBytes`
|
343
|
+
# function when using the `BINARY` encoding value. The following
|
344
|
+
# BigQuery types are allowed:
|
345
|
+
#
|
346
|
+
# * `BYTES`
|
347
|
+
# * `STRING`
|
348
|
+
# * `INTEGER`
|
349
|
+
# * `FLOAT`
|
350
|
+
# * `BOOLEAN`
|
351
|
+
#
|
352
|
+
# Default type is `BYTES`. Can also be set at the column family
|
353
|
+
# level. However, this value takes precedence when set at both
|
354
|
+
# levels.
|
355
|
+
#
|
356
|
+
# @param [String] new_type New type value
|
357
|
+
#
|
358
|
+
# @example
|
359
|
+
# require "google/cloud/bigquery"
|
360
|
+
#
|
361
|
+
# bigquery = Google::Cloud::Bigquery.new
|
362
|
+
#
|
363
|
+
# bigtable_url = "https://googleapis.com/bigtable/projects/..."
|
364
|
+
# bigtable_table = bigquery.external bigtable_url do |bt|
|
365
|
+
# bt.add_family "user" do |u|
|
366
|
+
# u.add_string "name" do |col|
|
367
|
+
# col.type # "STRING"
|
368
|
+
# col.type = "BYTES"
|
369
|
+
# col.type # "BYTES"
|
370
|
+
# end
|
371
|
+
# end
|
372
|
+
# end
|
373
|
+
#
|
374
|
+
def type= new_type
|
375
|
+
frozen_check!
|
376
|
+
@gapi.type = new_type
|
377
|
+
end
|
378
|
+
|
379
|
+
##
|
380
|
+
# @private Google API Client object.
|
381
|
+
def to_gapi
|
382
|
+
@gapi
|
383
|
+
end
|
384
|
+
|
385
|
+
##
|
386
|
+
# @private Google API Client object.
|
387
|
+
def self.from_gapi gapi
|
388
|
+
new_col = new
|
389
|
+
new_col.instance_variable_set :@gapi, gapi
|
390
|
+
new_col
|
391
|
+
end
|
392
|
+
|
393
|
+
protected
|
394
|
+
|
395
|
+
def frozen_check!
|
396
|
+
return unless frozen?
|
397
|
+
raise ArgumentError, "Cannot modify external data source when frozen"
|
398
|
+
end
|
399
|
+
end
|
400
|
+
end
|
401
|
+
end
|
402
|
+
end
|
403
|
+
end
|
404
|
+
end
|