File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed
lib/embulk/output/bigquery Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -224,6 +224,13 @@ def string_converter
224224 val # Users must care of BQ timestamp format
225225 }
226226 end
227+ when 'TIME'
228+ Proc . new { |val |
229+ next nil if val . nil?
230+ with_typecast_error ( val ) do |val |
231+ Time . parse ( val ) . strftime ( "%H:%M:%S.%6N" )
232+ end
233+ }
227234 when 'RECORD'
228235 Proc . new { |val |
229236 next nil if val . nil?
Original file line number Diff line number Diff line change @@ -262,6 +262,15 @@ def test_datetime
262262 assert_equal "2016-02-26 00:00:00" , converter . call ( "2016-02-26 00:00:00" )
263263 end
264264
265+ def test_time
266+ converter = ValueConverterFactory . new (
267+ SCHEMA_TYPE , 'TIME' ,
268+ timestamp_format : '%H:%M:%S'
269+ ) . create_converter
270+ assert_equal nil , converter . call ( nil )
271+ assert_equal "00:03:22.000000" , converter . call ( "00:03:22" )
272+ end
273+
265274 def test_record
266275 converter = ValueConverterFactory . new ( SCHEMA_TYPE , 'RECORD' ) . create_converter
267276 assert_equal ( { 'foo' => 'foo' } , converter . call ( %Q[{"foo":"foo"}] ) )
You can’t perform that action at this time.
0 commit comments