embulk-output-bigquery 0.7.2 → 0.7.3
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 +3 -0
- data/README.md +2 -2
- data/embulk-output-bigquery.gemspec +1 -1
- data/lib/embulk/output/bigquery/value_converter_factory.rb +13 -0
- data/test/test_value_converter_factory.rb +35 -0
- 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: 5162f2799cc8becf48b49080286afae0a992501f0bb2344f4c12f96bac41f750
|
|
4
|
+
data.tar.gz: b955eca9d5a75905f85a5e68e7bc5b40e01801e63ee0cd9f89c83b1dfbb2fb21
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 18cfcea89a9978f36cd7cd0c2a227692f2e03e0dfcb93f2a7dbc1cc8c26ccb36bc7d8c9a22bfc9d2c740ec8b09522ea904ccb6ebf92d54d57b18aebb5a6b93c6
|
|
7
|
+
data.tar.gz: 594e078d32a74a8cce63636dcc402354d87856f60ec268d20fd2030a9413472e203f2df2b43bec2c6ab3d8755c0b7b943d85e58a8c614bf87d0d9d6a15484a54
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
## 0.7.3 - 2024-08-28
|
|
2
|
+
* [enhancement] Add TIME type conversion to string converter (Thanks to p-eye)
|
|
3
|
+
|
|
1
4
|
## 0.7.2 - 2024-07-21
|
|
2
5
|
* [maintenance] Fix GitHub Actions #166
|
|
3
6
|
* [maintenance] Fix gcs_client in order to load data using gcs_bucket parameter (Thanks to kashira202111) #164
|
data/README.md
CHANGED
|
@@ -325,8 +325,8 @@ Column options are used to aid guessing BigQuery schema, or to define conversion
|
|
|
325
325
|
- boolean: `BOOLEAN`, `STRING` (default: `BOOLEAN`)
|
|
326
326
|
- long: `BOOLEAN`, `INTEGER`, `FLOAT`, `STRING`, `TIMESTAMP` (default: `INTEGER`)
|
|
327
327
|
- double: `INTEGER`, `FLOAT`, `STRING`, `TIMESTAMP` (default: `FLOAT`)
|
|
328
|
-
- string: `BOOLEAN`, `INTEGER`, `FLOAT`, `STRING`, `TIMESTAMP`, `DATETIME`, `DATE`, `RECORD` (default: `STRING`)
|
|
329
|
-
- timestamp: `INTEGER`, `FLOAT`, `STRING`, `TIMESTAMP`, `DATETIME`, `DATE` (default: `TIMESTAMP`)
|
|
328
|
+
- string: `BOOLEAN`, `INTEGER`, `FLOAT`, `STRING`, `TIME`, `TIMESTAMP`, `DATETIME`, `DATE`, `RECORD` (default: `STRING`)
|
|
329
|
+
- timestamp: `INTEGER`, `FLOAT`, `STRING`, `TIME`, `TIMESTAMP`, `DATETIME`, `DATE` (default: `TIMESTAMP`)
|
|
330
330
|
- json: `STRING`, `RECORD` (default: `STRING`)
|
|
331
331
|
- **mode**: BigQuery mode such as `NULLABLE`, `REQUIRED`, and `REPEATED` (string, default: `NULLABLE`)
|
|
332
332
|
- **fields**: Describes the nested schema fields if the type property is set to RECORD. Please note that this is **required** for `RECORD` column.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Gem::Specification.new do |spec|
|
|
2
2
|
spec.name = "embulk-output-bigquery"
|
|
3
|
-
spec.version = "0.7.
|
|
3
|
+
spec.version = "0.7.3"
|
|
4
4
|
spec.authors = ["Satoshi Akama", "Naotoshi Seo"]
|
|
5
5
|
spec.summary = "Google BigQuery output plugin for Embulk"
|
|
6
6
|
spec.description = "Embulk plugin that insert records to Google BigQuery."
|
|
@@ -224,6 +224,14 @@ module Embulk
|
|
|
224
224
|
val # Users must care of BQ timestamp format
|
|
225
225
|
}
|
|
226
226
|
end
|
|
227
|
+
when 'TIME'
|
|
228
|
+
# TimeWithZone doesn't affect any change to the time value
|
|
229
|
+
Proc.new {|val|
|
|
230
|
+
next nil if val.nil?
|
|
231
|
+
with_typecast_error(val) do |val|
|
|
232
|
+
TimeWithZone.set_zone_offset(Time.parse(val), zone_offset).strftime("%H:%M:%S.%6N")
|
|
233
|
+
end
|
|
234
|
+
}
|
|
227
235
|
when 'RECORD'
|
|
228
236
|
Proc.new {|val|
|
|
229
237
|
next nil if val.nil?
|
|
@@ -271,6 +279,11 @@ module Embulk
|
|
|
271
279
|
next nil if val.nil?
|
|
272
280
|
val.localtime(zone_offset).strftime("%Y-%m-%d %H:%M:%S.%6N")
|
|
273
281
|
}
|
|
282
|
+
when 'TIME'
|
|
283
|
+
Proc.new {|val|
|
|
284
|
+
next nil if val.nil?
|
|
285
|
+
val.localtime(zone_offset).strftime("%H:%M:%S.%6N")
|
|
286
|
+
}
|
|
274
287
|
else
|
|
275
288
|
raise NotSupportedType, "cannot take column type #{type} for timestamp column"
|
|
276
289
|
end
|
|
@@ -262,6 +262,23 @@ module Embulk
|
|
|
262
262
|
assert_equal "2016-02-26 00:00:00", converter.call("2016-02-26 00:00:00")
|
|
263
263
|
end
|
|
264
264
|
|
|
265
|
+
def test_time
|
|
266
|
+
converter = ValueConverterFactory.new(SCHEMA_TYPE, 'TIME').create_converter
|
|
267
|
+
assert_equal nil, converter.call(nil)
|
|
268
|
+
assert_equal "00:03:22.000000", converter.call("00:03:22")
|
|
269
|
+
assert_equal "15:22:00.000000", converter.call("3:22 PM")
|
|
270
|
+
assert_equal "03:22:00.000000", converter.call("3:22 AM")
|
|
271
|
+
assert_equal "00:00:00.000000", converter.call("2016-02-26 00:00:00")
|
|
272
|
+
|
|
273
|
+
# TimeWithZone doesn't affect any change to the time value
|
|
274
|
+
converter = ValueConverterFactory.new(
|
|
275
|
+
SCHEMA_TYPE, 'TIME', timezone: 'Asia/Tokyo'
|
|
276
|
+
).create_converter
|
|
277
|
+
assert_equal "15:00:01.000000", converter.call("15:00:01")
|
|
278
|
+
|
|
279
|
+
assert_raise { converter.call('foo') }
|
|
280
|
+
end
|
|
281
|
+
|
|
265
282
|
def test_record
|
|
266
283
|
converter = ValueConverterFactory.new(SCHEMA_TYPE, 'RECORD').create_converter
|
|
267
284
|
assert_equal({'foo'=>'foo'}, converter.call(%Q[{"foo":"foo"}]))
|
|
@@ -350,6 +367,24 @@ module Embulk
|
|
|
350
367
|
assert_raise { converter.call('foo') }
|
|
351
368
|
end
|
|
352
369
|
|
|
370
|
+
def test_time
|
|
371
|
+
converter = ValueConverterFactory.new(SCHEMA_TYPE, 'TIME').create_converter
|
|
372
|
+
assert_equal nil, converter.call(nil)
|
|
373
|
+
timestamp = Time.parse("2016-02-26 00:00:00.500000 +00:00")
|
|
374
|
+
expected = "00:00:00.500000"
|
|
375
|
+
assert_equal expected, converter.call(timestamp)
|
|
376
|
+
|
|
377
|
+
converter = ValueConverterFactory.new(
|
|
378
|
+
SCHEMA_TYPE, 'TIME', timezone: 'Asia/Tokyo'
|
|
379
|
+
).create_converter
|
|
380
|
+
assert_equal nil, converter.call(nil)
|
|
381
|
+
timestamp = Time.parse("2016-02-25 15:00:00.500000 +00:00")
|
|
382
|
+
expected = "00:00:00.500000"
|
|
383
|
+
assert_equal expected, converter.call(timestamp)
|
|
384
|
+
|
|
385
|
+
assert_raise { converter.call('foo') }
|
|
386
|
+
end
|
|
387
|
+
|
|
353
388
|
def test_record
|
|
354
389
|
assert_raise { ValueConverterFactory.new(SCHEMA_TYPE, 'RECORD').create_converter }
|
|
355
390
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: embulk-output-bigquery
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.7.
|
|
4
|
+
version: 0.7.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Satoshi Akama
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2024-
|
|
12
|
+
date: 2024-08-29 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: google-apis-storage_v1
|