google-cloud-bigquery 1.29.0 → 1.30.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 46f8452c3539550b91ccbde1577ca5e9d7f0d7ad39976a92103590f919d23d3b
4
- data.tar.gz: 62d2d147f332f0b0d8804eb08f7e5030b45b9068b0abb27e77987c04b670188f
3
+ metadata.gz: 316b03a95fd406a6382fb89e031e8cfe3388d7b244e53d0f3cc6749037437387
4
+ data.tar.gz: 00f3a68186e380fe588c7effb03e2f4ff9d4ca830d96f136df83d6df014abdc4
5
5
  SHA512:
6
- metadata.gz: e53218c1b8a8b8ce69463a78f29d27899308edb1a7c383d8b60b09080a1508b5ecb4a29f7527ebaed9c8bbdd080a2c3bf0b4a637e027aaae0c9e592c95979617
7
- data.tar.gz: f3665ef531ed461202e9cc58214d7b7d386a2e7ab1dbe990609d5414eb2e76f1ec05ab9f54333b578c69329cd5b1da254bc1f06639ec4c82154c0db625dc40db
6
+ metadata.gz: 7015cbe609aabf7f2bd57ee97f292c430733de8349b8349f97205de4a4192a3fc9b39d0163c626f393d1256a3354786b72e7f9f1dd94e2b262432c33c8287ad5
7
+ data.tar.gz: 843994c37a342681c9e53f3bde97dabcec668b313c73b3caf054ccf7ed6f422c8c48a6f2d947d097a6dfaf9803d96f110969096e22f47737b1a6fef8b8b494b2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Release History
2
2
 
3
+ ### 1.30.0 / 2021-04-20
4
+
5
+ #### Features
6
+
7
+ * Add support for BIGNUMERIC data type
8
+ * Add support for BIGNUMERIC data insert.
9
+ * Add support for BIGNUMERIC query params.
10
+ * Add #bignumeric to Schema, Table, LoadJob::Updater and Field.
11
+ * Update types tables in docs.
12
+
13
+ #### Bug Fixes
14
+
15
+ * Fix Table#time_partitioning_expiration=
16
+ * Accept nil argument.
17
+
3
18
  ### 1.29.0 / 2021-03-10
4
19
 
5
20
  #### Features
data/CONTRIBUTING.md CHANGED
@@ -119,15 +119,14 @@ If you alter an example's title, you may encounter breaking tests.
119
119
  ### BigQuery Acceptance Tests
120
120
 
121
121
  The BigQuery acceptance tests interact with the live service API. Follow the
122
- instructions in the {file:AUTHENTICATION.md Authentication guide} for enabling
122
+ instructions in the {file:AUTHENTICATION.md Authentication Guide} for enabling
123
123
  the BigQuery API. Occasionally, some API features may not yet be generally
124
124
  available, making it difficult for some contributors to successfully run the
125
125
  entire acceptance test suite. However, please ensure that you do successfully
126
126
  run acceptance tests for any code areas covered by your pull request.
127
127
 
128
128
  To run the acceptance tests, first create and configure a project in the Google
129
- Developers Console, as described in the {file:AUTHENTICATION.md Authentication
130
- guide}. Be sure to download the JSON KEY file. Make note of the PROJECT_ID and
129
+ Developers Console, as described in the {file:AUTHENTICATION.md Authentication Guide}. Be sure to download the JSON KEY file. Make note of the PROJECT_ID and
131
130
  the KEYFILE location on your system.
132
131
 
133
132
  Before you can run the BigQuery acceptance tests, you must first create indexes
data/OVERVIEW.md CHANGED
@@ -155,20 +155,21 @@ more complex types such as `ARRAY` and `STRUCT`.
155
155
 
156
156
  The BigQuery data types are converted to and from Ruby types as follows:
157
157
 
158
- | BigQuery | Ruby | Notes |
159
- |-------------|----------------|---|
160
- | `BOOL` | `true`/`false` | |
161
- | `INT64` | `Integer` | |
162
- | `FLOAT64` | `Float` | |
163
- | `NUMERIC` | `BigDecimal` | Will be rounded to 9 decimal places |
164
- | `STRING` | `String` | |
165
- | `DATETIME` | `DateTime` | `DATETIME` does not support time zone. |
166
- | `DATE` | `Date` | |
167
- | `TIMESTAMP` | `Time` | |
168
- | `TIME` | `Google::Cloud::BigQuery::Time` | |
169
- | `BYTES` | `File`, `IO`, `StringIO`, or similar | |
170
- | `ARRAY` | `Array` | Nested arrays and `nil` values are not supported. |
171
- | `STRUCT` | `Hash` | Hash keys may be strings or symbols. |
158
+ | BigQuery | Ruby | Notes |
159
+ |------------- |--------------------------------------|--------------------------------------------------------------|
160
+ | `BOOL` | `true`/`false` | |
161
+ | `INT64` | `Integer` | |
162
+ | `FLOAT64` | `Float` | |
163
+ | `NUMERIC` | `BigDecimal` | `BigDecimal` values will be rounded to scale 9. |
164
+ | `BIGNUMERIC` | converted to `BigDecimal` | Pass data as `String` and map query param values in `types`. |
165
+ | `STRING` | `String` | |
166
+ | `DATETIME` | `DateTime` | `DATETIME` does not support time zone. |
167
+ | `DATE` | `Date` | |
168
+ | `TIMESTAMP` | `Time` | |
169
+ | `TIME` | `Google::Cloud::BigQuery::Time` | |
170
+ | `BYTES` | `File`, `IO`, `StringIO`, or similar | |
171
+ | `ARRAY` | `Array` | Nested arrays, `nil` values are not supported. |
172
+ | `STRUCT` | `Hash` | Hash keys may be strings or symbols. |
172
173
 
173
174
  See [Data
174
175
  Types](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types)
@@ -26,25 +26,25 @@ module Google
26
26
  ##
27
27
  # @private
28
28
  #
29
- # Internal conversion of raw data values to/from Bigquery values
29
+ # Internal conversion of raw data values to/from BigQuery values
30
+ #
31
+ # | BigQuery | Ruby | Notes |
32
+ # |--------------|--------------------------------------|----------------------------------------------------|
33
+ # | `BOOL` | `true`/`false` | |
34
+ # | `INT64` | `Integer` | |
35
+ # | `FLOAT64` | `Float` | |
36
+ # | `NUMERIC` | `BigDecimal` | `BigDecimal` values will be rounded to scale 9. |
37
+ # | `BIGNUMERIC` | converted to `BigDecimal` | Pass data as `String`; map query params in `types`.|
38
+ # | `STRING` | `String` | |
39
+ # | `DATETIME` | `DateTime` | `DATETIME` does not support time zone. |
40
+ # | `DATE` | `Date` | |
41
+ # | `TIMESTAMP` | `Time` | |
42
+ # | `TIME` | `Google::Cloud::BigQuery::Time` | |
43
+ # | `BYTES` | `File`, `IO`, `StringIO`, or similar | |
44
+ # | `ARRAY` | `Array` | Nested arrays, `nil` values are not supported. |
45
+ # | `STRUCT` | `Hash` | Hash keys may be strings or symbols. |
30
46
  #
31
- # | BigQuery | Ruby | Notes |
32
- # |-------------|----------------|---|
33
- # | `BOOL` | `true`/`false` | |
34
- # | `INT64` | `Integer` | |
35
- # | `FLOAT64` | `Float` | |
36
- # | `NUMERIC` | `BigDecimal` | Will be rounded to 9 decimal places |
37
- # | `STRING` | `String` | |
38
- # | `DATETIME` | `DateTime` | `DATETIME` does not support time zone. |
39
- # | `DATE` | `Date` | |
40
- # | `TIMESTAMP` | `Time` | |
41
- # | `TIME` | `Google::Cloud::BigQuery::Time` | |
42
- # | `BYTES` | `File`, `IO`, `StringIO`, or similar | |
43
- # | `ARRAY` | `Array` | Nested arrays, `nil` values are not supported. |
44
- # | `STRUCT` | `Hash` | Hash keys may be strings or symbols. |
45
47
  module Convert
46
- ##
47
- # @private
48
48
  def self.format_rows rows, fields
49
49
  Array(rows).map do |row|
50
50
  # convert TableRow to hash to handle nested TableCell values
@@ -52,8 +52,6 @@ module Google
52
52
  end
53
53
  end
54
54
 
55
- ##
56
- # @private
57
55
  def self.format_row row, fields
58
56
  row_pairs = fields.zip(row[:f]).map do |f, v|
59
57
  [f.name.to_sym, format_value(v, f)]
@@ -90,6 +88,8 @@ module Google
90
88
  end
91
89
  elsif field.type == "NUMERIC"
92
90
  BigDecimal value[:v]
91
+ elsif field.type == "BIGNUMERIC"
92
+ BigDecimal value[:v]
93
93
  elsif field.type == "BOOLEAN"
94
94
  (value[:v] == "true" ? true : (value[:v] == "false" ? false : nil))
95
95
  elsif field.type == "BYTES"
@@ -107,30 +107,21 @@ module Google
107
107
  end
108
108
  end
109
109
 
110
- ##
111
- # @private
112
- def self.to_query_param param, type = nil
113
- type ||= default_query_param_type_for param
114
-
115
- Google::Apis::BigqueryV2::QueryParameter.new(
116
- parameter_type: to_query_param_type(type),
117
- parameter_value: to_query_param_value(param)
118
- )
119
- end
110
+ # rubocop:enable all
120
111
 
121
- ##
122
- # @private
123
- def self.to_query_param_value value
112
+ def self.to_query_param_value value, type = nil
124
113
  return Google::Apis::BigqueryV2::QueryParameterValue.new value: nil if value.nil?
125
114
 
126
- json_value = to_json_value value
115
+ json_value = to_json_value value, type
127
116
 
128
- if Array === json_value
129
- array_values = json_value.map { |v| to_query_param_value v }
117
+ case json_value
118
+ when Array
119
+ type = extract_array_type type
120
+ array_values = json_value.map { |v| to_query_param_value v, type }
130
121
  Google::Apis::BigqueryV2::QueryParameterValue.new array_values: array_values
131
- elsif Hash === json_value
132
- struct_pairs = json_value.map do |key, value|
133
- [String(key), to_query_param_value(value)]
122
+ when Hash
123
+ struct_pairs = json_value.map do |k, v|
124
+ [String(k), to_query_param_value(v, type)]
134
125
  end
135
126
  struct_values = Hash[struct_pairs]
136
127
  Google::Apis::BigqueryV2::QueryParameterValue.new struct_values: struct_values
@@ -141,12 +132,13 @@ module Google
141
132
  end
142
133
 
143
134
  def self.to_query_param_type type
144
- if Array === type
135
+ case type
136
+ when Array
145
137
  Google::Apis::BigqueryV2::QueryParameterType.new(
146
138
  type: "ARRAY".freeze,
147
139
  array_type: to_query_param_type(type.first)
148
140
  )
149
- elsif Hash === type
141
+ when Hash
150
142
  Google::Apis::BigqueryV2::QueryParameterType.new(
151
143
  type: "STRUCT".freeze,
152
144
  struct_types: type.map do |key, val|
@@ -157,10 +149,14 @@ module Google
157
149
  end
158
150
  )
159
151
  else
160
- Google::Apis::BigqueryV2::QueryParameterType.new(type: type.to_s.freeze)
152
+ Google::Apis::BigqueryV2::QueryParameterType.new type: type.to_s.freeze
161
153
  end
162
154
  end
163
155
 
156
+ # rubocop:disable Lint/DuplicateBranch
157
+ # rubocop:disable Metrics/CyclomaticComplexity
158
+ # rubocop:disable Style/GuardClause
159
+
164
160
  def self.default_query_param_type_for param
165
161
  raise ArgumentError, "nil params are not supported, must assign optional type" if param.nil?
166
162
 
@@ -200,9 +196,9 @@ module Google
200
196
  end
201
197
  [non_nil_values.first]
202
198
  when Hash
203
- Hash[param.map do |key, value|
204
- [key, default_query_param_type_for(value)]
205
- end]
199
+ param.transform_values do |value|
200
+ default_query_param_type_for value
201
+ end
206
202
  else
207
203
  if param.respond_to?(:read) && param.respond_to?(:rewind)
208
204
  :BYTES
@@ -212,9 +208,11 @@ module Google
212
208
  end
213
209
  end
214
210
 
215
- ##
216
- # @private
217
- def self.to_json_value value
211
+ # rubocop:enable Lint/DuplicateBranch
212
+ # rubocop:enable Metrics/CyclomaticComplexity
213
+ # rubocop:enable Style/GuardClause
214
+
215
+ def self.to_json_value value, type = nil
218
216
  if DateTime === value
219
217
  value.strftime "%Y-%m-%d %H:%M:%S.%6N"
220
218
  elsif Date === value
@@ -224,30 +222,46 @@ module Google
224
222
  elsif Bigquery::Time === value
225
223
  value.value
226
224
  elsif BigDecimal === value
227
- # Round to precision of 9
228
- value.finite? ? value.round(9).to_s("F") : value.to_s
225
+ if value.finite?
226
+ # Round to precision of 9 unless explicit `BIGNUMERIC`
227
+ bigdecimal = type == :BIGNUMERIC ? value : value.round(9)
228
+ bigdecimal.to_s "F"
229
+ else
230
+ value.to_s
231
+ end
229
232
  elsif value.respond_to?(:read) && value.respond_to?(:rewind)
230
233
  value.rewind
231
- Base64.strict_encode64(value.read.force_encoding("ASCII-8BIT"))
234
+ Base64.strict_encode64 value.read.force_encoding("ASCII-8BIT")
232
235
  elsif Array === value
233
- value.map { |v| to_json_value v }
236
+ type = extract_array_type type
237
+ value.map { |x| to_json_value x, type }
234
238
  elsif Hash === value
235
- Hash[value.map { |k, v| [k.to_s, to_json_value(v)] }]
239
+ Hash[value.map { |k, v| [k.to_s, to_json_value(v, type)] }]
236
240
  else
237
241
  value
238
242
  end
239
243
  end
240
244
 
241
- # rubocop:enable all
245
+ def self.to_query_param param, type = nil
246
+ type ||= default_query_param_type_for param
242
247
 
243
- ##
244
- # @private
245
- def self.to_json_rows rows
246
- rows.map { |row| to_json_row row }
248
+ Google::Apis::BigqueryV2::QueryParameter.new(
249
+ parameter_type: to_query_param_type(type),
250
+ parameter_value: to_query_param_value(param, type)
251
+ )
247
252
  end
248
253
 
249
254
  ##
250
- # @private
255
+ # Lists are specified by providing the type code in an array. For example, an array of integers are specified as
256
+ # `[:INT64]`. Extracts the symbol.
257
+ def self.extract_array_type type
258
+ return nil if type.nil?
259
+ unless type.is_a?(Array) && type.count == 1 && type.first.is_a?(Symbol)
260
+ raise ArgumentError, "types Array #{type.inspect} should include only a single symbol element."
261
+ end
262
+ type.first
263
+ end
264
+
251
265
  def self.to_json_row row
252
266
  Hash[row.map { |k, v| [k.to_s, to_json_value(v)] }]
253
267
  end
@@ -259,8 +273,6 @@ module Google
259
273
  end
260
274
 
261
275
  ##
262
- # @private
263
- #
264
276
  # Converts create disposition strings to API values.
265
277
  #
266
278
  # @return [String] API representation of create disposition.
@@ -279,8 +291,6 @@ module Google
279
291
  end
280
292
 
281
293
  ##
282
- # @private
283
- #
284
294
  # Converts write disposition strings to API values.
285
295
  #
286
296
  # @return [String] API representation of write disposition.
@@ -301,8 +311,6 @@ module Google
301
311
  end
302
312
 
303
313
  ##
304
- # @private
305
- #
306
314
  # Converts source format strings to API values.
307
315
  #
308
316
  # @return [String] API representation of source format.
@@ -325,8 +333,6 @@ module Google
325
333
  end
326
334
 
327
335
  ##
328
- # @private
329
- #
330
336
  # Converts file paths into source format by extension.
331
337
  #
332
338
  # @return [String] API representation of source format.
@@ -337,8 +343,6 @@ module Google
337
343
  end
338
344
 
339
345
  ##
340
- # @private
341
- #
342
346
  # Converts file path into source format by extension.
343
347
  #
344
348
  # @return [String] API representation of source format.
@@ -353,8 +357,6 @@ module Google
353
357
  end
354
358
 
355
359
  ##
356
- # @private
357
- #
358
360
  # Converts a primitive time value in milliseconds to a Ruby Time object.
359
361
  #
360
362
  # @return [Time, nil] The Ruby Time object, or nil if the given argument
@@ -365,8 +367,6 @@ module Google
365
367
  end
366
368
 
367
369
  ##
368
- # @private
369
- #
370
370
  # Converts a Ruby Time object to a primitive time value in milliseconds.
371
371
  #
372
372
  # @return [Integer, nil] The primitive time value in milliseconds, or
@@ -1140,35 +1140,37 @@ module Google
1140
1140
  #
1141
1141
  # Ruby types are mapped to BigQuery types as follows:
1142
1142
  #
1143
- # | BigQuery | Ruby | Notes |
1144
- # |-------------|--------------------------------------|------------------------------------------------|
1145
- # | `BOOL` | `true`/`false` | |
1146
- # | `INT64` | `Integer` | |
1147
- # | `FLOAT64` | `Float` | |
1148
- # | `NUMERIC` | `BigDecimal` | Will be rounded to 9 decimal places |
1149
- # | `STRING` | `String` | |
1150
- # | `DATETIME` | `DateTime` | `DATETIME` does not support time zone. |
1151
- # | `DATE` | `Date` | |
1152
- # | `TIMESTAMP` | `Time` | |
1153
- # | `TIME` | `Google::Cloud::BigQuery::Time` | |
1154
- # | `BYTES` | `File`, `IO`, `StringIO`, or similar | |
1155
- # | `ARRAY` | `Array` | Nested arrays, `nil` values are not supported. |
1156
- # | `STRUCT` | `Hash` | Hash keys may be strings or symbols. |
1143
+ # | BigQuery | Ruby | Notes |
1144
+ # |--------------|--------------------------------------|----------------------------------------------------|
1145
+ # | `BOOL` | `true`/`false` | |
1146
+ # | `INT64` | `Integer` | |
1147
+ # | `FLOAT64` | `Float` | |
1148
+ # | `NUMERIC` | `BigDecimal` | `BigDecimal` values will be rounded to scale 9. |
1149
+ # | `BIGNUMERIC` | | Query param values must be mapped in `types`. |
1150
+ # | `STRING` | `String` | |
1151
+ # | `DATETIME` | `DateTime` | `DATETIME` does not support time zone. |
1152
+ # | `DATE` | `Date` | |
1153
+ # | `TIMESTAMP` | `Time` | |
1154
+ # | `TIME` | `Google::Cloud::BigQuery::Time` | |
1155
+ # | `BYTES` | `File`, `IO`, `StringIO`, or similar | |
1156
+ # | `ARRAY` | `Array` | Nested arrays, `nil` values are not supported. |
1157
+ # | `STRUCT` | `Hash` | Hash keys may be strings or symbols. |
1157
1158
  #
1158
1159
  # See [Data Types](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types) for an overview
1159
1160
  # of each BigQuery data type, including allowed values.
1160
- # @param [Array, Hash] types Standard SQL only. Types of the SQL parameters in `params`. It is not always to
1161
- # infer the right SQL type from a value in `params`. In these cases, `types` must be used to specify the SQL
1162
- # type for these values.
1161
+ # @param [Array, Hash] types Standard SQL only. Types of the SQL parameters in `params`. It is not always
1162
+ # possible to infer the right SQL type from a value in `params`. In these cases, `types` must be used to
1163
+ # specify the SQL type for these values.
1163
1164
  #
1164
- # Must match the value type passed to `params`. This must be an `Array` when the query uses positional query
1165
- # parameters. This must be an `Hash` when the query uses named query parameters. The values should be BigQuery
1166
- # type codes from the following list:
1165
+ # Arguments must match the value type passed to `params`. This must be an `Array` when the query uses
1166
+ # positional query parameters. This must be an `Hash` when the query uses named query parameters. The values
1167
+ # should be BigQuery type codes from the following list:
1167
1168
  #
1168
1169
  # * `:BOOL`
1169
1170
  # * `:INT64`
1170
1171
  # * `:FLOAT64`
1171
1172
  # * `:NUMERIC`
1173
+ # * `:BIGNUMERIC`
1172
1174
  # * `:STRING`
1173
1175
  # * `:DATETIME`
1174
1176
  # * `:DATE`
@@ -1481,35 +1483,37 @@ module Google
1481
1483
  #
1482
1484
  # Ruby types are mapped to BigQuery types as follows:
1483
1485
  #
1484
- # | BigQuery | Ruby | Notes |
1485
- # |-------------|--------------------------------------|------------------------------------------------|
1486
- # | `BOOL` | `true`/`false` | |
1487
- # | `INT64` | `Integer` | |
1488
- # | `FLOAT64` | `Float` | |
1489
- # | `NUMERIC` | `BigDecimal` | Will be rounded to 9 decimal places |
1490
- # | `STRING` | `String` | |
1491
- # | `DATETIME` | `DateTime` | `DATETIME` does not support time zone. |
1492
- # | `DATE` | `Date` | |
1493
- # | `TIMESTAMP` | `Time` | |
1494
- # | `TIME` | `Google::Cloud::BigQuery::Time` | |
1495
- # | `BYTES` | `File`, `IO`, `StringIO`, or similar | |
1496
- # | `ARRAY` | `Array` | Nested arrays, `nil` values are not supported. |
1497
- # | `STRUCT` | `Hash` | Hash keys may be strings or symbols. |
1486
+ # | BigQuery | Ruby | Notes |
1487
+ # |--------------|--------------------------------------|----------------------------------------------------|
1488
+ # | `BOOL` | `true`/`false` | |
1489
+ # | `INT64` | `Integer` | |
1490
+ # | `FLOAT64` | `Float` | |
1491
+ # | `NUMERIC` | `BigDecimal` | `BigDecimal` values will be rounded to scale 9. |
1492
+ # | `BIGNUMERIC` | | Query param values must be mapped in `types`. |
1493
+ # | `STRING` | `String` | |
1494
+ # | `DATETIME` | `DateTime` | `DATETIME` does not support time zone. |
1495
+ # | `DATE` | `Date` | |
1496
+ # | `TIMESTAMP` | `Time` | |
1497
+ # | `TIME` | `Google::Cloud::BigQuery::Time` | |
1498
+ # | `BYTES` | `File`, `IO`, `StringIO`, or similar | |
1499
+ # | `ARRAY` | `Array` | Nested arrays, `nil` values are not supported. |
1500
+ # | `STRUCT` | `Hash` | Hash keys may be strings or symbols. |
1498
1501
  #
1499
1502
  # See [Data Types](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types) for an overview
1500
1503
  # of each BigQuery data type, including allowed values.
1501
- # @param [Array, Hash] types Standard SQL only. Types of the SQL parameters in `params`. It is not always to
1502
- # infer the right SQL type from a value in `params`. In these cases, `types` must be used to specify the SQL
1503
- # type for these values.
1504
+ # @param [Array, Hash] types Standard SQL only. Types of the SQL parameters in `params`. It is not always
1505
+ # possible to infer the right SQL type from a value in `params`. In these cases, `types` must be used to
1506
+ # specify the SQL type for these values.
1504
1507
  #
1505
- # Must match the value type passed to `params`. This must be an `Array` when the query uses positional query
1506
- # parameters. This must be an `Hash` when the query uses named query parameters. The values should be BigQuery
1507
- # type codes from the following list:
1508
+ # Arguments must match the value type passed to `params`. This must be an `Array` when the query uses
1509
+ # positional query parameters. This must be an `Hash` when the query uses named query parameters. The values
1510
+ # should be BigQuery type codes from the following list:
1508
1511
  #
1509
1512
  # * `:BOOL`
1510
1513
  # * `:INT64`
1511
1514
  # * `:FLOAT64`
1512
1515
  # * `:NUMERIC`
1516
+ # * `:BIGNUMERIC`
1513
1517
  # * `:STRING`
1514
1518
  # * `:DATETIME`
1515
1519
  # * `:DATE`
@@ -2408,6 +2412,21 @@ module Google
2408
2412
  # the need to complete a load operation before the data can appear in
2409
2413
  # query results.
2410
2414
  #
2415
+ # Simple Ruby types are generally accepted per JSON rules, along with the following support for BigQuery's more
2416
+ # complex types:
2417
+ #
2418
+ # | BigQuery | Ruby | Notes |
2419
+ # |--------------|--------------------------------------|----------------------------------------------------|
2420
+ # | `NUMERIC` | `BigDecimal` | `BigDecimal` values will be rounded to scale 9. |
2421
+ # | `BIGNUMERIC` | `String` | Pass as `String` to avoid rounding to scale 9. |
2422
+ # | `DATETIME` | `DateTime` | `DATETIME` does not support time zone. |
2423
+ # | `DATE` | `Date` | |
2424
+ # | `TIMESTAMP` | `Time` | |
2425
+ # | `TIME` | `Google::Cloud::BigQuery::Time` | |
2426
+ # | `BYTES` | `File`, `IO`, `StringIO`, or similar | |
2427
+ # | `ARRAY` | `Array` | Nested arrays, `nil` values are not supported. |
2428
+ # | `STRUCT` | `Hash` | Hash keys may be strings or symbols. |
2429
+ #
2411
2430
  # Because BigQuery's streaming API is designed for high insertion rates,
2412
2431
  # modifications to the underlying table metadata are eventually
2413
2432
  # consistent when interacting with the streaming system. In most cases
@@ -2422,7 +2441,10 @@ module Google
2422
2441
  #
2423
2442
  # @param [String] table_id The ID of the destination table.
2424
2443
  # @param [Hash, Array<Hash>] rows A hash object or array of hash objects
2425
- # containing the data. Required.
2444
+ # containing the data. Required. `BigDecimal` values will be rounded to
2445
+ # scale 9 to conform with the BigQuery `NUMERIC` data type. To avoid
2446
+ # rounding `BIGNUMERIC` type values with scale greater than 9, use `String`
2447
+ # instead of `BigDecimal`.
2426
2448
  # @param [Array<String|Symbol>, Symbol] insert_ids A unique ID for each row. BigQuery uses this property to
2427
2449
  # detect duplicate insertion requests on a best-effort basis. For more information, see [data
2428
2450
  # consistency](https://cloud.google.com/bigquery/streaming-data-into-bigquery#dataconsistency). Optional. If
@@ -2489,6 +2511,18 @@ module Google
2489
2511
  # t.schema.integer "age", mode: :required
2490
2512
  # end
2491
2513
  #
2514
+ # @example Pass `BIGNUMERIC` value as a string to avoid rounding to scale 9 in the conversion from `BigDecimal`:
2515
+ # require "google/cloud/bigquery"
2516
+ #
2517
+ # bigquery = Google::Cloud::Bigquery.new
2518
+ # dataset = bigquery.dataset "my_dataset"
2519
+ #
2520
+ # row = {
2521
+ # "my_numeric" => BigDecimal("123456798.987654321"),
2522
+ # "my_bignumeric" => "123456798.98765432100001" # BigDecimal would be rounded, use String instead!
2523
+ # }
2524
+ # dataset.insert "my_table", row
2525
+ #
2492
2526
  # @!group Data
2493
2527
  #
2494
2528
  def insert table_id, rows, insert_ids: nil, skip_invalid: nil, ignore_unknown: nil, autocreate: nil, &block