embulk-output-bigquery 0.6.2 → 0.6.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 +4 -0
- data/README.md +4 -4
- data/embulk-output-bigquery.gemspec +1 -1
- data/lib/embulk/output/bigquery/value_converter_factory.rb +12 -0
- data/test/test_helper.rb +4 -1
- data/test/test_value_converter_factory.rb +42 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b3d7d7d675d8428946f81517d1002f667f4fafe
|
4
|
+
data.tar.gz: 25940b93f70492675869d3c4dd50f83f8b7347cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97a2aff66c765f24289717ac79e0a25a6bf31ee3ec5b84b64c96e8573382b31b0a27c30f06692a296b3bfedd70ea9f34f1a451cea7de27d3fa4c61a7502bab98
|
7
|
+
data.tar.gz: b795d47af337e109dfafb9f41a0a720d0eb314c7ba7219193648505ec9dffa3874215b5d311256f625228a4f3e52b73153ee3d694a3d2f88d4c2fd0dd24960b1
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -307,17 +307,17 @@ Column options are used to aid guessing BigQuery schema, or to define conversion
|
|
307
307
|
|
308
308
|
- **column_options**: advanced: an array of options for columns
|
309
309
|
- **name**: column name
|
310
|
-
- **type**: BigQuery type such as `BOOLEAN`, `INTEGER`, `FLOAT`, `STRING`, `TIMESTAMP`, and `RECORD`. See belows for supported conversion type.
|
310
|
+
- **type**: BigQuery type such as `BOOLEAN`, `INTEGER`, `FLOAT`, `STRING`, `TIMESTAMP`, `DATE`, and `RECORD`. See belows for supported conversion type.
|
311
311
|
- boolean: `BOOLEAN`, `STRING` (default: `BOOLEAN`)
|
312
312
|
- long: `BOOLEAN`, `INTEGER`, `FLOAT`, `STRING`, `TIMESTAMP` (default: `INTEGER`)
|
313
313
|
- double: `INTEGER`, `FLOAT`, `STRING`, `TIMESTAMP` (default: `FLOAT`)
|
314
|
-
- string: `BOOLEAN`, `INTEGER`, `FLOAT`, `STRING`, `TIMESTAMP`, `RECORD` (default: `STRING`)
|
315
|
-
- timestamp: `INTEGER`, `FLOAT`, `STRING`, `TIMESTAMP` (default: `TIMESTAMP`)
|
314
|
+
- string: `BOOLEAN`, `INTEGER`, `FLOAT`, `STRING`, `TIMESTAMP`, `DATE`, `RECORD` (default: `STRING`)
|
315
|
+
- timestamp: `INTEGER`, `FLOAT`, `STRING`, `TIMESTAMP`, `DATE` (default: `TIMESTAMP`)
|
316
316
|
- json: `STRING`, `RECORD` (default: `STRING`)
|
317
317
|
- **mode**: BigQuery mode such as `NULLABLE`, `REQUIRED`, and `REPEATED` (string, default: `NULLABLE`)
|
318
318
|
- **fields**: Describes the nested schema fields if the type property is set to RECORD. Please note that this is **required** for `RECORD` column.
|
319
319
|
- **timestamp_format**: timestamp format to convert into/from `timestamp` (string, default is `default_timestamp_format`)
|
320
|
-
- **timezone**: timezone to convert into/from `timestamp` (string, default is `default_timezone`).
|
320
|
+
- **timezone**: timezone to convert into/from `timestamp`, `date` (string, default is `default_timezone`).
|
321
321
|
- **default_timestamp_format**: default timestamp format for column_options (string, default is "%Y-%m-%d %H:%M:%S.%6N")
|
322
322
|
- **default_timezone**: default timezone for column_options (string, default is "UTC")
|
323
323
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "embulk-output-bigquery"
|
3
|
-
spec.version = "0.6.
|
3
|
+
spec.version = "0.6.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."
|
@@ -203,6 +203,13 @@ module Embulk
|
|
203
203
|
val # Users must care of BQ timestamp format
|
204
204
|
}
|
205
205
|
end
|
206
|
+
when 'DATE'
|
207
|
+
Proc.new {|val|
|
208
|
+
next nil if val.nil?
|
209
|
+
with_typecast_error(val) do |val|
|
210
|
+
TimeWithZone.set_zone_offset(Time.parse(val), zone_offset).strftime("%Y-%m-%d")
|
211
|
+
end
|
212
|
+
}
|
206
213
|
when 'RECORD'
|
207
214
|
Proc.new {|val|
|
208
215
|
next nil if val.nil?
|
@@ -240,6 +247,11 @@ module Embulk
|
|
240
247
|
next nil if val.nil?
|
241
248
|
val.strftime("%Y-%m-%d %H:%M:%S.%6N %:z")
|
242
249
|
}
|
250
|
+
when 'DATE'
|
251
|
+
Proc.new {|val|
|
252
|
+
next nil if val.nil?
|
253
|
+
val.localtime(zone_offset).strftime("%Y-%m-%d")
|
254
|
+
}
|
243
255
|
else
|
244
256
|
raise NotSupportedType, "cannot take column type #{type} for timestamp column"
|
245
257
|
end
|
data/test/test_helper.rb
CHANGED
@@ -62,7 +62,8 @@ module Embulk
|
|
62
62
|
Column.new({index: 2, name: 'double', type: :double}),
|
63
63
|
Column.new({index: 3, name: 'string', type: :string}),
|
64
64
|
Column.new({index: 4, name: 'timestamp', type: :timestamp}),
|
65
|
-
Column.new({index: 5, name: '
|
65
|
+
Column.new({index: 5, name: 'date', type: :timestamp}),
|
66
|
+
Column.new({index: 6, name: 'json', type: :json}),
|
66
67
|
])
|
67
68
|
task = {
|
68
69
|
'column_options' => [
|
@@ -71,6 +72,7 @@ module Embulk
|
|
71
72
|
{'name' => 'double', 'type' => 'STRING'},
|
72
73
|
{'name' => 'string', 'type' => 'INTEGER'},
|
73
74
|
{'name' => 'timestamp', 'type' => 'INTEGER'},
|
75
|
+
{'name' => 'date', 'type' => 'DATE'},
|
74
76
|
{'name' => 'json', 'type' => 'RECORD', 'fields' => [
|
75
77
|
{ 'name' => 'key1', 'type' => 'STRING' },
|
76
78
|
]},
|
@@ -82,6 +84,7 @@ module Embulk
|
|
82
84
|
{name: 'double', type: 'STRING'},
|
83
85
|
{name: 'string', type: 'INTEGER'},
|
84
86
|
{name: 'timestamp', type: 'INTEGER'},
|
87
|
+
{name: 'date', type: 'DATE'},
|
85
88
|
{name: 'json', type: 'RECORD', fields: [
|
86
89
|
{name: 'key1', type: 'STRING'},
|
87
90
|
]},
|
@@ -90,6 +90,10 @@ module Embulk
|
|
90
90
|
assert_raise { ValueConverterFactory.new(SCHEMA_TYPE, 'TIMESTAMP').create_converter }
|
91
91
|
end
|
92
92
|
|
93
|
+
def test_date
|
94
|
+
assert_raise { ValueConverterFactory.new(SCHEMA_TYPE, 'DATE').create_converter }
|
95
|
+
end
|
96
|
+
|
93
97
|
def test_record
|
94
98
|
assert_raise { ValueConverterFactory.new(SCHEMA_TYPE, 'RECORD').create_converter }
|
95
99
|
end
|
@@ -130,6 +134,10 @@ module Embulk
|
|
130
134
|
assert_equal 1408452095, converter.call(1408452095)
|
131
135
|
end
|
132
136
|
|
137
|
+
def test_date
|
138
|
+
assert_raise { ValueConverterFactory.new(SCHEMA_TYPE, 'DATE').create_converter }
|
139
|
+
end
|
140
|
+
|
133
141
|
def test_record
|
134
142
|
assert_raise { ValueConverterFactory.new(SCHEMA_TYPE, 'RECORD').create_converter }
|
135
143
|
end
|
@@ -166,6 +174,10 @@ module Embulk
|
|
166
174
|
assert_equal 1408452095.188766, converter.call(1408452095.188766)
|
167
175
|
end
|
168
176
|
|
177
|
+
def test_date
|
178
|
+
assert_raise { ValueConverterFactory.new(SCHEMA_TYPE, 'DATE').create_converter }
|
179
|
+
end
|
180
|
+
|
169
181
|
def test_record
|
170
182
|
assert_raise { ValueConverterFactory.new(SCHEMA_TYPE, 'RECORD').create_converter }
|
171
183
|
end
|
@@ -216,6 +228,14 @@ module Embulk
|
|
216
228
|
assert_equal "2016-02-26 00:00:00", converter.call("2016-02-26 00:00:00")
|
217
229
|
end
|
218
230
|
|
231
|
+
def test_date
|
232
|
+
converter = ValueConverterFactory.new(SCHEMA_TYPE, 'DATE').create_converter
|
233
|
+
assert_equal nil, converter.call(nil)
|
234
|
+
assert_equal "2016-02-26", converter.call("2016-02-26")
|
235
|
+
assert_equal "2016-02-26", converter.call("2016-02-26 00:00:00")
|
236
|
+
assert_raise { converter.call('foo') }
|
237
|
+
end
|
238
|
+
|
219
239
|
def test_record
|
220
240
|
converter = ValueConverterFactory.new(SCHEMA_TYPE, 'RECORD').create_converter
|
221
241
|
assert_equal({'foo'=>'foo'}, converter.call(%Q[{"foo":"foo"}]))
|
@@ -268,6 +288,24 @@ module Embulk
|
|
268
288
|
assert_equal expected, converter.call(Time.at(subject).utc)
|
269
289
|
end
|
270
290
|
|
291
|
+
def test_date
|
292
|
+
converter = ValueConverterFactory.new(SCHEMA_TYPE, 'DATE').create_converter
|
293
|
+
assert_equal nil, converter.call(nil)
|
294
|
+
timestamp = Time.parse("2016-02-26 00:00:00.500000 +00:00")
|
295
|
+
expected = "2016-02-26"
|
296
|
+
assert_equal expected, converter.call(timestamp)
|
297
|
+
|
298
|
+
converter = ValueConverterFactory.new(
|
299
|
+
SCHEMA_TYPE, 'DATE', timezone: 'Asia/Tokyo'
|
300
|
+
).create_converter
|
301
|
+
assert_equal nil, converter.call(nil)
|
302
|
+
timestamp = Time.parse("2016-02-25 15:00:00.500000 +00:00")
|
303
|
+
expected = "2016-02-26"
|
304
|
+
assert_equal expected, converter.call(timestamp)
|
305
|
+
|
306
|
+
assert_raise { converter.call('foo') }
|
307
|
+
end
|
308
|
+
|
271
309
|
def test_record
|
272
310
|
assert_raise { ValueConverterFactory.new(SCHEMA_TYPE, 'RECORD').create_converter }
|
273
311
|
end
|
@@ -298,6 +336,10 @@ module Embulk
|
|
298
336
|
assert_raise { ValueConverterFactory.new(SCHEMA_TYPE, 'TIMESTAMP').create_converter }
|
299
337
|
end
|
300
338
|
|
339
|
+
def test_date
|
340
|
+
assert_raise { ValueConverterFactory.new(SCHEMA_TYPE, 'DATE').create_converter }
|
341
|
+
end
|
342
|
+
|
301
343
|
def test_record
|
302
344
|
converter = ValueConverterFactory.new(SCHEMA_TYPE, 'RECORD').create_converter
|
303
345
|
assert_equal nil, converter.call(nil)
|
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.6.
|
4
|
+
version: 0.6.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: 2019-10-
|
12
|
+
date: 2019-10-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|