google-cloud-bigquery 1.18.1 → 1.21.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -155,10 +155,87 @@ module Google
155
155
  end
156
156
 
157
157
  ###
158
- # Checks if the table is time-partitioned. See [Partitioned
158
+ # Checks if the table is range partitioned. See [Creating and using integer range partitioned
159
+ # tables](https://cloud.google.com/bigquery/docs/creating-integer-range-partitions).
160
+ #
161
+ # @return [Boolean, nil] `true` when the table is range partitioned, or
162
+ # `false` otherwise, if the object is a resource (see {#resource?});
163
+ # `nil` if the object is a reference (see {#reference?}).
164
+ #
165
+ # @!group Attributes
166
+ #
167
+ def range_partitioning?
168
+ return nil if reference?
169
+ !@gapi.range_partitioning.nil?
170
+ end
171
+
172
+ ###
173
+ # The field on which the table is range partitioned, if any. The field must be a top-level `NULLABLE/REQUIRED`
174
+ # field. The only supported type is `INTEGER/INT64`. See [Creating and using integer range partitioned
175
+ # tables](https://cloud.google.com/bigquery/docs/creating-integer-range-partitions).
176
+ #
177
+ # @return [Integer, nil] The range partition field, or `nil` if not range partitioned or the object is a
178
+ # reference (see {#reference?}).
179
+ #
180
+ # @!group Attributes
181
+ #
182
+ def range_partitioning_field
183
+ return nil if reference?
184
+ ensure_full_data!
185
+ @gapi.range_partitioning.field if range_partitioning?
186
+ end
187
+
188
+ ###
189
+ # The start of range partitioning, inclusive. See [Creating and using integer range partitioned
190
+ # tables](https://cloud.google.com/bigquery/docs/creating-integer-range-partitions).
191
+ #
192
+ # @return [Integer, nil] The start of range partitioning, inclusive, or `nil` if not range partitioned or the
193
+ # object is a reference (see {#reference?}).
194
+ #
195
+ # @!group Attributes
196
+ #
197
+ def range_partitioning_start
198
+ return nil if reference?
199
+ ensure_full_data!
200
+ @gapi.range_partitioning.range.start if range_partitioning?
201
+ end
202
+
203
+ ###
204
+ # The width of each interval. See [Creating and using integer range partitioned
205
+ # tables](https://cloud.google.com/bigquery/docs/creating-integer-range-partitions).
206
+ #
207
+ # @return [Integer, nil] The width of each interval, for data in range partitions, or `nil` if not range
208
+ # partitioned or the object is a reference (see {#reference?}).
209
+ #
210
+ # @!group Attributes
211
+ #
212
+ def range_partitioning_interval
213
+ return nil if reference?
214
+ ensure_full_data!
215
+ return nil unless range_partitioning?
216
+ @gapi.range_partitioning.range.interval
217
+ end
218
+
219
+ ###
220
+ # The end of range partitioning, exclusive. See [Creating and using integer range partitioned
221
+ # tables](https://cloud.google.com/bigquery/docs/creating-integer-range-partitions).
222
+ #
223
+ # @return [Integer, nil] The end of range partitioning, exclusive, or `nil` if not range partitioned or the
224
+ # object is a reference (see {#reference?}).
225
+ #
226
+ # @!group Attributes
227
+ #
228
+ def range_partitioning_end
229
+ return nil if reference?
230
+ ensure_full_data!
231
+ @gapi.range_partitioning.range.end if range_partitioning?
232
+ end
233
+
234
+ ###
235
+ # Checks if the table is time partitioned. See [Partitioned
159
236
  # Tables](https://cloud.google.com/bigquery/docs/partitioned-tables).
160
237
  #
161
- # @return [Boolean, nil] `true` when the table is time-partitioned, or
238
+ # @return [Boolean, nil] `true` when the table is time partitioned, or
162
239
  # `false` otherwise, if the object is a resource (see {#resource?});
163
240
  # `nil` if the object is a reference (see {#reference?}).
164
241
  #
@@ -170,10 +247,10 @@ module Google
170
247
  end
171
248
 
172
249
  ###
173
- # The period for which the table is partitioned, if any. See
250
+ # The period for which the table is time partitioned, if any. See
174
251
  # [Partitioned Tables](https://cloud.google.com/bigquery/docs/partitioned-tables).
175
252
  #
176
- # @return [String, nil] The partition type. Currently the only supported
253
+ # @return [String, nil] The time partition type. Currently the only supported
177
254
  # value is "DAY", or `nil` if the object is a reference (see
178
255
  # {#reference?}).
179
256
  #
@@ -186,14 +263,14 @@ module Google
186
263
  end
187
264
 
188
265
  ##
189
- # Sets the partitioning for the table. See [Partitioned
266
+ # Sets the time partitioning type for the table. See [Partitioned
190
267
  # Tables](https://cloud.google.com/bigquery/docs/partitioned-tables).
191
268
  #
192
- # You can only set partitioning when creating a table as in
193
- # the example below. BigQuery does not allow you to change partitioning
269
+ # You can only set time partitioning when creating a table as in
270
+ # the example below. BigQuery does not allow you to change time partitioning
194
271
  # on an existing table.
195
272
  #
196
- # @param [String] type The partition type. Currently the only
273
+ # @param [String] type The time partition type. Currently the only
197
274
  # supported value is "DAY".
198
275
  #
199
276
  # @example
@@ -201,8 +278,12 @@ module Google
201
278
  #
202
279
  # bigquery = Google::Cloud::Bigquery.new
203
280
  # dataset = bigquery.dataset "my_dataset"
204
- # table = dataset.create_table "my_table" do |table|
205
- # table.time_partitioning_type = "DAY"
281
+ # table = dataset.create_table "my_table" do |t|
282
+ # t.schema do |schema|
283
+ # schema.timestamp "dob", mode: :required
284
+ # end
285
+ # t.time_partitioning_type = "DAY"
286
+ # t.time_partitioning_field = "dob"
206
287
  # end
207
288
  #
208
289
  # @!group Attributes
@@ -215,13 +296,13 @@ module Google
215
296
  end
216
297
 
217
298
  ###
218
- # The field on which the table is partitioned, if any. If not
219
- # set, the destination table is partitioned by pseudo column
220
- # `_PARTITIONTIME`; if set, the table is partitioned by this field. See
299
+ # The field on which the table is time partitioned, if any. If not
300
+ # set, the destination table is time partitioned by pseudo column
301
+ # `_PARTITIONTIME`; if set, the table is time partitioned by this field. See
221
302
  # [Partitioned Tables](https://cloud.google.com/bigquery/docs/partitioned-tables).
222
303
  #
223
- # @return [String, nil] The partition field, if a field was configured.
224
- # `nil` if not partitioned, not set (partitioned by pseudo column
304
+ # @return [String, nil] The time partition field, if a field was configured.
305
+ # `nil` if not time partitioned, not set (time partitioned by pseudo column
225
306
  # '_PARTITIONTIME') or the object is a reference (see {#reference?}).
226
307
  #
227
308
  # @!group Attributes
@@ -233,19 +314,19 @@ module Google
233
314
  end
234
315
 
235
316
  ##
236
- # Sets the field on which to partition the table. If not
237
- # set, the destination table is partitioned by pseudo column
238
- # `_PARTITIONTIME`; if set, the table is partitioned by this field. See
317
+ # Sets the field on which to time partition the table. If not
318
+ # set, the destination table is time partitioned by pseudo column
319
+ # `_PARTITIONTIME`; if set, the table is time partitioned by this field. See
239
320
  # [Partitioned Tables](https://cloud.google.com/bigquery/docs/partitioned-tables).
240
- # The table must also be partitioned.
321
+ # The table must also be time partitioned.
241
322
  #
242
323
  # See {Table#time_partitioning_type=}.
243
324
  #
244
- # You can only set the partitioning field while creating a table as in
245
- # the example below. BigQuery does not allow you to change partitioning
325
+ # You can only set the time partitioning field while creating a table as in
326
+ # the example below. BigQuery does not allow you to change time partitioning
246
327
  # on an existing table.
247
328
  #
248
- # @param [String] field The partition field. The field must be a
329
+ # @param [String] field The time partition field. The field must be a
249
330
  # top-level TIMESTAMP or DATE field. Its mode must be NULLABLE or
250
331
  # REQUIRED.
251
332
  #
@@ -254,12 +335,12 @@ module Google
254
335
  #
255
336
  # bigquery = Google::Cloud::Bigquery.new
256
337
  # dataset = bigquery.dataset "my_dataset"
257
- # table = dataset.create_table "my_table" do |table|
258
- # table.time_partitioning_type = "DAY"
259
- # table.time_partitioning_field = "dob"
260
- # table.schema do |schema|
338
+ # table = dataset.create_table "my_table" do |t|
339
+ # t.schema do |schema|
261
340
  # schema.timestamp "dob", mode: :required
262
341
  # end
342
+ # t.time_partitioning_type = "DAY"
343
+ # t.time_partitioning_field = "dob"
263
344
  # end
264
345
  #
265
346
  # @!group Attributes
@@ -272,11 +353,11 @@ module Google
272
353
  end
273
354
 
274
355
  ###
275
- # The expiration for the table partitions, if any, in seconds. See
356
+ # The expiration for the time partitions, if any, in seconds. See
276
357
  # [Partitioned Tables](https://cloud.google.com/bigquery/docs/partitioned-tables).
277
358
  #
278
359
  # @return [Integer, nil] The expiration time, in seconds, for data in
279
- # partitions, or `nil` if not present or the object is a reference
360
+ # time partitions, or `nil` if not present or the object is a reference
280
361
  # (see {#reference?}).
281
362
  #
282
363
  # @!group Attributes
@@ -290,9 +371,9 @@ module Google
290
371
  end
291
372
 
292
373
  ##
293
- # Sets the partition expiration for the table. See [Partitioned
374
+ # Sets the time partition expiration for the table. See [Partitioned
294
375
  # Tables](https://cloud.google.com/bigquery/docs/partitioned-tables).
295
- # The table must also be partitioned.
376
+ # The table must also be time partitioned.
296
377
  #
297
378
  # See {Table#time_partitioning_type=}.
298
379
  #
@@ -301,16 +382,20 @@ module Google
301
382
  # the update to comply with ETag-based optimistic concurrency control.
302
383
  #
303
384
  # @param [Integer] expiration An expiration time, in seconds,
304
- # for data in partitions.
385
+ # for data in time partitions.
305
386
  #
306
387
  # @example
307
388
  # require "google/cloud/bigquery"
308
389
  #
309
390
  # bigquery = Google::Cloud::Bigquery.new
310
391
  # dataset = bigquery.dataset "my_dataset"
311
- # table = dataset.create_table "my_table" do |table|
312
- # table.time_partitioning_type = "DAY"
313
- # table.time_partitioning_expiration = 86_400
392
+ # table = dataset.create_table "my_table" do |t|
393
+ # t.schema do |schema|
394
+ # schema.timestamp "dob", mode: :required
395
+ # end
396
+ # t.time_partitioning_type = "DAY"
397
+ # t.time_partitioning_field = "dob"
398
+ # t.time_partitioning_expiration = 86_400
314
399
  # end
315
400
  #
316
401
  # @!group Attributes
@@ -356,8 +441,8 @@ module Google
356
441
  #
357
442
  # bigquery = Google::Cloud::Bigquery.new
358
443
  # dataset = bigquery.dataset "my_dataset"
359
- # table = dataset.create_table "my_table" do |table|
360
- # table.require_partition_filter = true
444
+ # table = dataset.create_table "my_table" do |t|
445
+ # t.require_partition_filter = true
361
446
  # end
362
447
  #
363
448
  # @!group Attributes
@@ -387,7 +472,7 @@ module Google
387
472
 
388
473
  ###
389
474
  # One or more fields on which data should be clustered. Must be
390
- # specified with time-based partitioning, data in the table will be
475
+ # specified with time partitioning, data in the table will be
391
476
  # first partitioned and subsequently clustered. The order of the
392
477
  # returned fields determines the sort order of the data.
393
478
  #
@@ -1096,12 +1181,20 @@ module Google
1096
1181
  # SQL](https://cloud.google.com/bigquery/docs/reference/legacy-sql)
1097
1182
  # dialect. Optional. The default value is false.
1098
1183
  # @param [Array<String>, String] udfs User-defined function resources
1099
- # used in the query. May be either a code resource to load from a
1100
- # Google Cloud Storage URI (`gs://bucket/path`), or an inline resource
1184
+ # used in a legacy SQL query. May be either a code resource to load from
1185
+ # a Google Cloud Storage URI (`gs://bucket/path`), or an inline resource
1101
1186
  # that contains code for a user-defined function (UDF). Providing an
1102
1187
  # inline code resource is equivalent to providing a URI for a file
1103
- # containing the same code. See [User-Defined
1104
- # Functions](https://cloud.google.com/bigquery/docs/reference/standard-sql/user-defined-functions).
1188
+ # containing the same code.
1189
+ #
1190
+ # This parameter is used for defining User Defined Function (UDF)
1191
+ # resources only when using legacy SQL. Users of standard SQL should
1192
+ # leverage either DDL (e.g. `CREATE [TEMPORARY] FUNCTION ...`) or the
1193
+ # Routines API to define UDF resources.
1194
+ #
1195
+ # For additional information on migrating, see: [Migrating to
1196
+ # standard SQL - Differences in user-defined JavaScript
1197
+ # functions](https://cloud.google.com/bigquery/docs/reference/standard-sql/migrating-from-legacy-sql#differences_in_user-defined_javascript_functions)
1105
1198
  #
1106
1199
  # @example
1107
1200
  # require "google/cloud/bigquery"
@@ -1193,12 +1286,13 @@ module Google
1193
1286
  # table = dataset.table "my_table"
1194
1287
  #
1195
1288
  # data = table.data
1289
+ #
1290
+ # # Iterate over the first page of results
1196
1291
  # data.each do |row|
1197
- # puts row[:first_name]
1198
- # end
1199
- # if data.next?
1200
- # more_data = data.next if data.next?
1292
+ # puts row[:name]
1201
1293
  # end
1294
+ # # Retrieve the next page of results
1295
+ # data = data.next if data.next?
1202
1296
  #
1203
1297
  # @example Retrieve all rows of data: (See {Data#all})
1204
1298
  # require "google/cloud/bigquery"
@@ -1208,8 +1302,9 @@ module Google
1208
1302
  # table = dataset.table "my_table"
1209
1303
  #
1210
1304
  # data = table.data
1305
+ #
1211
1306
  # data.all do |row|
1212
- # puts row[:first_name]
1307
+ # puts row[:name]
1213
1308
  # end
1214
1309
  #
1215
1310
  # @!group Data
@@ -1217,8 +1312,7 @@ module Google
1217
1312
  def data token: nil, max: nil, start: nil
1218
1313
  ensure_service!
1219
1314
  reload! unless resource_full?
1220
- options = { token: token, max: max, start: start }
1221
- data_json = service.list_tabledata dataset_id, table_id, options
1315
+ data_json = service.list_tabledata dataset_id, table_id, token: token, max: max, start: start
1222
1316
  Data.from_gapi_json data_json, gapi, nil, service
1223
1317
  end
1224
1318
 
@@ -1978,12 +2072,13 @@ module Google
1978
2072
  #
1979
2073
  # @param [Hash, Array<Hash>] rows A hash object or array of hash objects
1980
2074
  # containing the data. Required.
1981
- # @param [Array<String>] insert_ids A unique ID for each row. BigQuery
1982
- # uses this property to detect duplicate insertion requests on a
1983
- # best-effort basis. For more information, see [data
1984
- # consistency](https://cloud.google.com/bigquery/streaming-data-into-bigquery#dataconsistency).
1985
- # Optional. If not provided, the client library will assign a UUID to
1986
- # each row before the request is sent.
2075
+ # @param [Array<String|Symbol>, Symbol] insert_ids A unique ID for each row. BigQuery uses this property to
2076
+ # detect duplicate insertion requests on a best-effort basis. For more information, see [data
2077
+ # consistency](https://cloud.google.com/bigquery/streaming-data-into-bigquery#dataconsistency). Optional. If
2078
+ # not provided, the client library will assign a UUID to each row before the request is sent.
2079
+ #
2080
+ # The value `:skip` can be provided to skip the generation of IDs for all rows, or to skip the generation of an
2081
+ # ID for a specific row in the array.
1987
2082
  # @param [Boolean] skip_invalid Insert all valid rows of a request, even
1988
2083
  # if invalid rows exist. The default value is `false`, which causes
1989
2084
  # the entire request to fail if any invalid rows exist.
@@ -2023,12 +2118,14 @@ module Google
2023
2118
  #
2024
2119
  def insert rows, insert_ids: nil, skip_invalid: nil, ignore_unknown: nil
2025
2120
  rows = [rows] if rows.is_a? Hash
2121
+ raise ArgumentError, "No rows provided" if rows.empty?
2122
+
2123
+ insert_ids = Array.new(rows.count) { :skip } if insert_ids == :skip
2026
2124
  insert_ids = Array insert_ids
2027
2125
  if insert_ids.count.positive? && insert_ids.count != rows.count
2028
2126
  raise ArgumentError, "insert_ids must be the same size as rows"
2029
2127
  end
2030
- rows = [rows] if rows.is_a? Hash
2031
- raise ArgumentError, "No rows provided" if rows.empty?
2128
+
2032
2129
  ensure_service!
2033
2130
  options = { skip_invalid: skip_invalid, ignore_unknown: ignore_unknown, insert_ids: insert_ids }
2034
2131
  gapi = service.insert_tabledata dataset_id, table_id, rows, options
@@ -2162,7 +2259,7 @@ module Google
2162
2259
  # table = dataset.table "my_table", skip_lookup: true
2163
2260
  # table.exists? # true
2164
2261
  #
2165
- def exists? force: nil
2262
+ def exists? force: false
2166
2263
  return gapi_exists? if force
2167
2264
  # If we have a value, return it
2168
2265
  return @exists unless @exists.nil?
@@ -2276,7 +2373,7 @@ module Google
2276
2373
  end
2277
2374
 
2278
2375
  ##
2279
- # @private New lazy Table object without making an HTTP request.
2376
+ # @private New lazy Table object without making an HTTP request, for use with the skip_lookup option.
2280
2377
  def self.new_reference project_id, dataset_id, table_id, service
2281
2378
  raise ArgumentError, "dataset_id is required" unless dataset_id
2282
2379
  raise ArgumentError, "table_id is required" unless table_id
@@ -2505,20 +2602,182 @@ module Google
2505
2602
  end
2506
2603
 
2507
2604
  ##
2508
- # Yielded to a block to accumulate changes for a patch request.
2605
+ # Yielded to a block to accumulate changes for a create request. See {Dataset#create_table}.
2509
2606
  class Updater < Table
2510
2607
  ##
2511
- # A list of attributes that were updated.
2608
+ # @private A list of attributes that were updated.
2512
2609
  attr_reader :updates
2513
2610
 
2514
2611
  ##
2515
- # Create an Updater object.
2612
+ # @private Create an Updater object.
2516
2613
  def initialize gapi
2517
2614
  @updates = []
2518
2615
  @gapi = gapi
2519
2616
  @schema = nil
2520
2617
  end
2521
2618
 
2619
+ ##
2620
+ # Sets the field on which to range partition the table. See [Creating and using integer range partitioned
2621
+ # tables](https://cloud.google.com/bigquery/docs/creating-integer-range-partitions).
2622
+ #
2623
+ # See {Table::Updater#range_partitioning_start=}, {Table::Updater#range_partitioning_interval=} and
2624
+ # {Table::Updater#range_partitioning_end=}.
2625
+ #
2626
+ # You can only set range partitioning when creating a table as in the example below. BigQuery does not allow
2627
+ # you to change partitioning on an existing table.
2628
+ #
2629
+ # @param [String] field The range partition field. The table is partitioned by this
2630
+ # field. The field must be a top-level `NULLABLE/REQUIRED` field. The only supported
2631
+ # type is `INTEGER/INT64`.
2632
+ #
2633
+ # @example
2634
+ # require "google/cloud/bigquery"
2635
+ #
2636
+ # bigquery = Google::Cloud::Bigquery.new
2637
+ # dataset = bigquery.dataset "my_dataset"
2638
+ #
2639
+ # table = dataset.create_table "my_table" do |t|
2640
+ # t.schema do |schema|
2641
+ # schema.integer "my_table_id", mode: :required
2642
+ # schema.string "my_table_data", mode: :required
2643
+ # end
2644
+ # t.range_partitioning_field = "my_table_id"
2645
+ # t.range_partitioning_start = 0
2646
+ # t.range_partitioning_interval = 10
2647
+ # t.range_partitioning_end = 100
2648
+ # end
2649
+ #
2650
+ # @!group Attributes
2651
+ #
2652
+ def range_partitioning_field= field
2653
+ reload! unless resource_full?
2654
+ @gapi.range_partitioning ||= Google::Apis::BigqueryV2::RangePartitioning.new(
2655
+ range: Google::Apis::BigqueryV2::RangePartitioning::Range.new
2656
+ )
2657
+ @gapi.range_partitioning.field = field
2658
+ patch_gapi! :range_partitioning
2659
+ end
2660
+
2661
+ ##
2662
+ # Sets the start of range partitioning, inclusive, for the table. See [Creating and using integer range
2663
+ # partitioned tables](https://cloud.google.com/bigquery/docs/creating-integer-range-partitions).
2664
+ #
2665
+ # You can only set range partitioning when creating a table as in the example below. BigQuery does not allow
2666
+ # you to change partitioning on an existing table.
2667
+ #
2668
+ # See {Table::Updater#range_partitioning_field=}, {Table::Updater#range_partitioning_interval=} and
2669
+ # {Table::Updater#range_partitioning_end=}.
2670
+ #
2671
+ # @param [Integer] range_start The start of range partitioning, inclusive.
2672
+ #
2673
+ # @example
2674
+ # require "google/cloud/bigquery"
2675
+ #
2676
+ # bigquery = Google::Cloud::Bigquery.new
2677
+ # dataset = bigquery.dataset "my_dataset"
2678
+ #
2679
+ # table = dataset.create_table "my_table" do |t|
2680
+ # t.schema do |schema|
2681
+ # schema.integer "my_table_id", mode: :required
2682
+ # schema.string "my_table_data", mode: :required
2683
+ # end
2684
+ # t.range_partitioning_field = "my_table_id"
2685
+ # t.range_partitioning_start = 0
2686
+ # t.range_partitioning_interval = 10
2687
+ # t.range_partitioning_end = 100
2688
+ # end
2689
+ #
2690
+ # @!group Attributes
2691
+ #
2692
+ def range_partitioning_start= range_start
2693
+ reload! unless resource_full?
2694
+ @gapi.range_partitioning ||= Google::Apis::BigqueryV2::RangePartitioning.new(
2695
+ range: Google::Apis::BigqueryV2::RangePartitioning::Range.new
2696
+ )
2697
+ @gapi.range_partitioning.range.start = range_start
2698
+ patch_gapi! :range_partitioning
2699
+ end
2700
+
2701
+ ##
2702
+ # Sets width of each interval for data in range partitions. See [Creating and using integer range partitioned
2703
+ # tables](https://cloud.google.com/bigquery/docs/creating-integer-range-partitions).
2704
+ #
2705
+ # You can only set range partitioning when creating a table as in the example below. BigQuery does not allow
2706
+ # you to change partitioning on an existing table.
2707
+ #
2708
+ # See {Table::Updater#range_partitioning_field=}, {Table::Updater#range_partitioning_start=} and
2709
+ # {Table::Updater#range_partitioning_end=}.
2710
+ #
2711
+ # @param [Integer] range_interval The width of each interval, for data in partitions.
2712
+ #
2713
+ # @example
2714
+ # require "google/cloud/bigquery"
2715
+ #
2716
+ # bigquery = Google::Cloud::Bigquery.new
2717
+ # dataset = bigquery.dataset "my_dataset"
2718
+ #
2719
+ # table = dataset.create_table "my_table" do |t|
2720
+ # t.schema do |schema|
2721
+ # schema.integer "my_table_id", mode: :required
2722
+ # schema.string "my_table_data", mode: :required
2723
+ # end
2724
+ # t.range_partitioning_field = "my_table_id"
2725
+ # t.range_partitioning_start = 0
2726
+ # t.range_partitioning_interval = 10
2727
+ # t.range_partitioning_end = 100
2728
+ # end
2729
+ #
2730
+ # @!group Attributes
2731
+ #
2732
+ def range_partitioning_interval= range_interval
2733
+ reload! unless resource_full?
2734
+ @gapi.range_partitioning ||= Google::Apis::BigqueryV2::RangePartitioning.new(
2735
+ range: Google::Apis::BigqueryV2::RangePartitioning::Range.new
2736
+ )
2737
+ @gapi.range_partitioning.range.interval = range_interval
2738
+ patch_gapi! :range_partitioning
2739
+ end
2740
+
2741
+ ##
2742
+ # Sets the end of range partitioning, exclusive, for the table. See [Creating and using integer range
2743
+ # partitioned tables](https://cloud.google.com/bigquery/docs/creating-integer-range-partitions).
2744
+ #
2745
+ # You can only set range partitioning when creating a table as in the example below. BigQuery does not allow
2746
+ # you to change partitioning on an existing table.
2747
+ #
2748
+ # See {Table::Updater#range_partitioning_start=}, {Table::Updater#range_partitioning_interval=} and
2749
+ # {Table::Updater#range_partitioning_field=}.
2750
+ #
2751
+ # @param [Integer] range_end The end of range partitioning, exclusive.
2752
+ #
2753
+ # @example
2754
+ # require "google/cloud/bigquery"
2755
+ #
2756
+ # bigquery = Google::Cloud::Bigquery.new
2757
+ # dataset = bigquery.dataset "my_dataset"
2758
+ #
2759
+ # table = dataset.create_table "my_table" do |t|
2760
+ # t.schema do |schema|
2761
+ # schema.integer "my_table_id", mode: :required
2762
+ # schema.string "my_table_data", mode: :required
2763
+ # end
2764
+ # t.range_partitioning_field = "my_table_id"
2765
+ # t.range_partitioning_start = 0
2766
+ # t.range_partitioning_interval = 10
2767
+ # t.range_partitioning_end = 100
2768
+ # end
2769
+ #
2770
+ # @!group Attributes
2771
+ #
2772
+ def range_partitioning_end= range_end
2773
+ reload! unless resource_full?
2774
+ @gapi.range_partitioning ||= Google::Apis::BigqueryV2::RangePartitioning.new(
2775
+ range: Google::Apis::BigqueryV2::RangePartitioning::Range.new
2776
+ )
2777
+ @gapi.range_partitioning.range.end = range_end
2778
+ patch_gapi! :range_partitioning
2779
+ end
2780
+
2522
2781
  ##
2523
2782
  # Sets one or more fields on which data should be clustered. Must be
2524
2783
  # specified with time-based partitioning, data in the table will be
@@ -2550,15 +2809,15 @@ module Google
2550
2809
  #
2551
2810
  # bigquery = Google::Cloud::Bigquery.new
2552
2811
  # dataset = bigquery.dataset "my_dataset"
2553
- # table = dataset.create_table "my_table" do |table|
2554
- # table.time_partitioning_type = "DAY"
2555
- # table.time_partitioning_field = "dob"
2556
- # table.schema do |schema|
2812
+ # table = dataset.create_table "my_table" do |t|
2813
+ # t.schema do |schema|
2557
2814
  # schema.timestamp "dob", mode: :required
2558
2815
  # schema.string "first_name", mode: :required
2559
2816
  # schema.string "last_name", mode: :required
2560
2817
  # end
2561
- # table.clustering_fields = ["last_name", "first_name"]
2818
+ # t.time_partitioning_type = "DAY"
2819
+ # t.time_partitioning_field = "dob"
2820
+ # t.clustering_fields = ["last_name", "first_name"]
2562
2821
  # end
2563
2822
  #
2564
2823
  # @!group Attributes
@@ -2955,8 +3214,97 @@ module Google
2955
3214
  schema.record name, description: description, mode: mode, &block
2956
3215
  end
2957
3216
 
3217
+ # rubocop:disable Style/MethodDefParentheses
3218
+
3219
+ ##
3220
+ # @raise [RuntimeError] not implemented
3221
+ def data(*)
3222
+ raise "not implemented in #{self.class}"
3223
+ end
3224
+
3225
+ ##
3226
+ # @raise [RuntimeError] not implemented
3227
+ def copy_job(*)
3228
+ raise "not implemented in #{self.class}"
3229
+ end
3230
+
3231
+ ##
3232
+ # @raise [RuntimeError] not implemented
3233
+ def copy(*)
3234
+ raise "not implemented in #{self.class}"
3235
+ end
3236
+
3237
+ ##
3238
+ # @raise [RuntimeError] not implemented
3239
+ def extract_job(*)
3240
+ raise "not implemented in #{self.class}"
3241
+ end
3242
+
3243
+ ##
3244
+ # @raise [RuntimeError] not implemented
3245
+ def extract(*)
3246
+ raise "not implemented in #{self.class}"
3247
+ end
3248
+
3249
+ ##
3250
+ # @raise [RuntimeError] not implemented
3251
+ def load_job(*)
3252
+ raise "not implemented in #{self.class}"
3253
+ end
3254
+
3255
+ ##
3256
+ # @raise [RuntimeError] not implemented
3257
+ def load(*)
3258
+ raise "not implemented in #{self.class}"
3259
+ end
3260
+
2958
3261
  ##
2959
- # Make sure any access changes are saved
3262
+ # @raise [RuntimeError] not implemented
3263
+ def insert(*)
3264
+ raise "not implemented in #{self.class}"
3265
+ end
3266
+
3267
+ ##
3268
+ # @raise [RuntimeError] not implemented
3269
+ def insert_async(*)
3270
+ raise "not implemented in #{self.class}"
3271
+ end
3272
+
3273
+ ##
3274
+ # @raise [RuntimeError] not implemented
3275
+ def delete
3276
+ raise "not implemented in #{self.class}"
3277
+ end
3278
+
3279
+ ##
3280
+ # @raise [RuntimeError] not implemented
3281
+ def query_job(*)
3282
+ raise "not implemented in #{self.class}"
3283
+ end
3284
+
3285
+ ##
3286
+ # @raise [RuntimeError] not implemented
3287
+ def query(*)
3288
+ raise "not implemented in #{self.class}"
3289
+ end
3290
+
3291
+ ##
3292
+ # @raise [RuntimeError] not implemented
3293
+ def external(*)
3294
+ raise "not implemented in #{self.class}"
3295
+ end
3296
+
3297
+ ##
3298
+ # @raise [RuntimeError] not implemented
3299
+ def reload!
3300
+ raise "not implemented in #{self.class}"
3301
+ end
3302
+ alias refresh! reload!
3303
+
3304
+ # rubocop:enable Style/MethodDefParentheses
3305
+
3306
+ ##
3307
+ # @private Make sure any access changes are saved
2960
3308
  def check_for_mutated_schema!
2961
3309
  return if @schema.nil?
2962
3310
  return unless @schema.changed?
@@ -2964,6 +3312,8 @@ module Google
2964
3312
  patch_gapi! :schema
2965
3313
  end
2966
3314
 
3315
+ ##
3316
+ # @private
2967
3317
  def to_gapi
2968
3318
  check_for_mutated_schema!
2969
3319
  @gapi