File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -22,10 +22,14 @@ class ArrowCompressor < Compressor
22
22
def configure ( conf )
23
23
super
24
24
25
- @arrow_schema = ::Arrow ::Schema . new ( @compress . schema )
26
25
if INVALID_COMBINATIONS [ @compress . arrow_format ] &.include? @compress . arrow_compression
27
26
raise Fluent ::ConfigError , "#{ @compress . arrow_format } unsupported with #{ @compress . arrow_format } "
28
27
end
28
+
29
+ @arrow_schema = Arrow ::Schema . new ( @compress . schema )
30
+ @options = Arrow ::JSONReadOptions . new
31
+ @options . schema = @arrow_schema
32
+ @options . unexpected_field_behavior = :ignore
29
33
end
30
34
31
35
def ext
@@ -39,7 +43,7 @@ def content_type
39
43
def compress ( chunk , tmp )
40
44
buffer = Arrow ::Buffer . new ( chunk . read )
41
45
stream = Arrow ::BufferInputStream . new ( buffer )
42
- table = Arrow ::JSONReader . new ( stream )
46
+ table = Arrow ::JSONReader . new ( stream , @options )
43
47
44
48
table . read . save ( tmp ,
45
49
format : @compress . arrow_format ,
Original file line number Diff line number Diff line change @@ -48,15 +48,17 @@ def test_compress
48
48
49
49
chunk = Fluent ::Plugin ::Buffer ::MemoryChunk . new ( Object . new )
50
50
d1 = { "test_string" => 'record1' , "test_uint64" => 1 }
51
- d2 = { "test_string" => 'record2' , "test_uint64" => 2 }
51
+ d2 = { "test_string" => 'record2' , "test_uint64" => 2 , "unexpected_field" => false }
52
+ expected_d2 = d2 . dup
53
+ expected_d2 . delete "unexpected_field"
52
54
chunk . append ( [ d1 . to_json + "\n " , d2 . to_json + "\n " ] )
53
55
54
56
Tempfile . create do |tmp |
55
57
c . compress ( chunk , tmp )
56
58
Arrow ::MemoryMappedInputStream . open ( tmp . path ) do |input |
57
59
reader = Arrow ::RecordBatchFileReader . new ( input )
58
60
reader . each do |record_batch |
59
- assert_equal ( [ d1 , d2 ] , record_batch . collect ( &:to_h ) )
61
+ assert_equal ( [ d1 , expected_d2 ] , record_batch . collect ( &:to_h ) )
60
62
end
61
63
end
62
64
end
You can’t perform that action at this time.
0 commit comments