red-arrow 4.0.1 → 7.0.0

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.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +10 -0
  3. data/README.md +23 -0
  4. data/ext/arrow/arrow.cpp +3 -0
  5. data/ext/arrow/converters.cpp +5 -0
  6. data/ext/arrow/converters.hpp +126 -0
  7. data/ext/arrow/extconf.rb +13 -0
  8. data/ext/arrow/memory-view.cpp +311 -0
  9. data/ext/arrow/memory-view.hpp +26 -0
  10. data/ext/arrow/raw-records.cpp +1 -0
  11. data/ext/arrow/values.cpp +1 -0
  12. data/lib/arrow/aggregate-node-options.rb +35 -0
  13. data/lib/arrow/aggregation.rb +46 -0
  14. data/lib/arrow/array-builder.rb +5 -0
  15. data/lib/arrow/array.rb +12 -0
  16. data/lib/arrow/binary-dictionary-array-builder.rb +27 -0
  17. data/lib/arrow/buffer.rb +10 -6
  18. data/lib/arrow/column-containable.rb +100 -1
  19. data/lib/arrow/constructor-arguments-gc-guardable.rb +25 -0
  20. data/lib/arrow/datum.rb +102 -0
  21. data/lib/arrow/equal-options.rb +38 -0
  22. data/lib/arrow/expression.rb +48 -0
  23. data/lib/arrow/file-system.rb +34 -0
  24. data/lib/arrow/function.rb +52 -0
  25. data/lib/arrow/group.rb +116 -124
  26. data/lib/arrow/loader.rb +58 -0
  27. data/lib/arrow/map-array-builder.rb +109 -0
  28. data/lib/arrow/map-array.rb +26 -0
  29. data/lib/arrow/map-data-type.rb +89 -0
  30. data/lib/arrow/path-extension.rb +1 -1
  31. data/lib/arrow/record-batch-reader.rb +41 -0
  32. data/lib/arrow/record-batch.rb +0 -2
  33. data/lib/arrow/s3-global-options.rb +38 -0
  34. data/lib/arrow/scalar.rb +32 -0
  35. data/lib/arrow/slicer.rb +44 -143
  36. data/lib/arrow/sort-key.rb +61 -55
  37. data/lib/arrow/sort-options.rb +8 -8
  38. data/lib/arrow/source-node-options.rb +32 -0
  39. data/lib/arrow/string-dictionary-array-builder.rb +27 -0
  40. data/lib/arrow/symbol-values-appendable.rb +34 -0
  41. data/lib/arrow/table-concatenate-options.rb +36 -0
  42. data/lib/arrow/table-formatter.rb +141 -17
  43. data/lib/arrow/table-list-formatter.rb +5 -3
  44. data/lib/arrow/table-loader.rb +119 -44
  45. data/lib/arrow/table-saver.rb +36 -5
  46. data/lib/arrow/table-table-formatter.rb +7 -31
  47. data/lib/arrow/table.rb +112 -40
  48. data/lib/arrow/version.rb +1 -1
  49. data/red-arrow.gemspec +1 -9
  50. data/test/helper.rb +3 -0
  51. data/test/raw-records/test-dense-union-array.rb +14 -0
  52. data/test/raw-records/test-list-array.rb +19 -0
  53. data/test/raw-records/test-map-array.rb +441 -0
  54. data/test/raw-records/test-sparse-union-array.rb +14 -0
  55. data/test/raw-records/test-struct-array.rb +15 -0
  56. data/test/test-array-builder.rb +7 -0
  57. data/test/test-array.rb +34 -0
  58. data/test/test-binary-dictionary-array-builder.rb +103 -0
  59. data/test/test-boolean-scalar.rb +26 -0
  60. data/test/test-csv-loader.rb +8 -8
  61. data/test/test-expression.rb +40 -0
  62. data/test/test-float-scalar.rb +46 -0
  63. data/test/test-function.rb +210 -0
  64. data/test/test-group.rb +75 -51
  65. data/test/test-map-array-builder.rb +110 -0
  66. data/test/test-map-array.rb +33 -0
  67. data/test/test-map-data-type.rb +36 -0
  68. data/test/test-memory-view.rb +434 -0
  69. data/test/test-record-batch-reader.rb +46 -0
  70. data/test/test-record-batch.rb +42 -0
  71. data/test/test-slicer.rb +166 -167
  72. data/test/test-string-dictionary-array-builder.rb +103 -0
  73. data/test/test-table.rb +376 -56
  74. data/test/values/test-dense-union-array.rb +14 -0
  75. data/test/values/test-list-array.rb +17 -0
  76. data/test/values/test-map-array.rb +433 -0
  77. data/test/values/test-sparse-union-array.rb +14 -0
  78. data/test/values/test-struct-array.rb +15 -0
  79. metadata +117 -168
data/test/test-table.rb CHANGED
@@ -53,26 +53,26 @@ class TableTest < Test::Unit::TestCase
53
53
  target_rows_raw = [nil, true, true, false, true, false, true, true]
54
54
  target_rows = Arrow::BooleanArray.new(target_rows_raw)
55
55
  assert_equal(<<-TABLE, @table.slice(target_rows).to_s)
56
- count visible
57
- 0
58
- 1 2 false
59
- 2 4
60
- 3 16 true
61
- 4 64
62
- 5 128
56
+ count visible
57
+ 0 (null) (null)
58
+ 1 2 false
59
+ 2 4 (null)
60
+ 3 16 true
61
+ 4 64 (null)
62
+ 5 128 (null)
63
63
  TABLE
64
64
  end
65
65
 
66
66
  test("Array: boolean") do
67
67
  target_rows_raw = [nil, true, true, false, true, false, true, true]
68
68
  assert_equal(<<-TABLE, @table.slice(target_rows_raw).to_s)
69
- count visible
70
- 0
71
- 1 2 false
72
- 2 4
73
- 3 16 true
74
- 4 64
75
- 5 128
69
+ count visible
70
+ 0 (null) (null)
71
+ 1 2 false
72
+ 2 4 (null)
73
+ 3 16 true
74
+ 4 64 (null)
75
+ 5 128 (null)
76
76
  TABLE
77
77
  end
78
78
 
@@ -100,7 +100,7 @@ class TableTest < Test::Unit::TestCase
100
100
  test("Range: positive: include end") do
101
101
  assert_equal(<<-TABLE, @table.slice(2..4).to_s)
102
102
  count visible
103
- 0 4
103
+ 0 4 (null)
104
104
  1 8 true
105
105
  2 16 true
106
106
  TABLE
@@ -109,7 +109,7 @@ class TableTest < Test::Unit::TestCase
109
109
  test("Range: positive: exclude end") do
110
110
  assert_equal(<<-TABLE, @table.slice(2...4).to_s)
111
111
  count visible
112
- 0 4
112
+ 0 4 (null)
113
113
  1 8 true
114
114
  TABLE
115
115
  end
@@ -119,7 +119,7 @@ class TableTest < Test::Unit::TestCase
119
119
  count visible
120
120
  0 16 true
121
121
  1 32 false
122
- 2 64
122
+ 2 64 (null)
123
123
  TABLE
124
124
  end
125
125
 
@@ -147,6 +147,104 @@ class TableTest < Test::Unit::TestCase
147
147
  TABLE
148
148
  end
149
149
 
150
+ test("{key: Number}") do
151
+ assert_equal(<<-TABLE, @table.slice(count: 16).to_s)
152
+ count visible
153
+ 0 16 true
154
+ TABLE
155
+ end
156
+
157
+ test("{key: String}") do
158
+ table = Arrow::Table.new(name: Arrow::StringArray.new(["a", "b", "c"]))
159
+ assert_equal(<<-TABLE, table.slice(name: 'b').to_s)
160
+ name
161
+ 0 b
162
+ TABLE
163
+ end
164
+
165
+ test("{key: true}") do
166
+ assert_equal(<<-TABLE, @table.slice(visible: true).to_s)
167
+ count visible
168
+ 0 1 true
169
+ 1 (null) (null)
170
+ 2 8 true
171
+ 3 16 true
172
+ 4 (null) (null)
173
+ 5 (null) (null)
174
+ TABLE
175
+ end
176
+
177
+ test("{key: false}") do
178
+ assert_equal(<<-TABLE, @table.slice(visible: false).to_s)
179
+ count visible
180
+ 0 2 false
181
+ 1 (null) (null)
182
+ 2 32 false
183
+ 3 (null) (null)
184
+ 4 (null) (null)
185
+ TABLE
186
+ end
187
+
188
+ test("{key: Range}: beginless include end") do
189
+ assert_equal(<<-TABLE, @table.slice(count: ..8).to_s)
190
+ count visible
191
+ 0 1 true
192
+ 1 2 false
193
+ 2 4 (null)
194
+ 3 8 true
195
+ TABLE
196
+ end
197
+
198
+ test("{key: Range}: beginless exclude end") do
199
+ assert_equal(<<-TABLE, @table.slice(count: ...8).to_s)
200
+ count visible
201
+ 0 1 true
202
+ 1 2 false
203
+ 2 4 (null)
204
+ TABLE
205
+ end
206
+
207
+ test("{key: Range}: endless") do
208
+ assert_equal(<<-TABLE, @table.slice(count: 16..).to_s)
209
+ count visible
210
+ 0 16 true
211
+ 1 32 false
212
+ 2 64 (null)
213
+ 3 128 (null)
214
+ TABLE
215
+ end
216
+
217
+ test("{key: Range}: include end") do
218
+ assert_equal(<<-TABLE, @table.slice(count: 1..16).to_s)
219
+ count visible
220
+ 0 1 true
221
+ 1 2 false
222
+ 2 4 (null)
223
+ 3 8 true
224
+ 4 16 true
225
+ TABLE
226
+ end
227
+
228
+ test("{key: Range}: exclude end") do
229
+ assert_equal(<<-TABLE, @table.slice(count: 1...16).to_s)
230
+ count visible
231
+ 0 1 true
232
+ 1 2 false
233
+ 2 4 (null)
234
+ 3 8 true
235
+ TABLE
236
+ end
237
+
238
+ test("{key1: Range, key2: true}") do
239
+ assert_equal(<<-TABLE, @table.slice(count: 0..8, visible: false).to_s)
240
+ count visible
241
+ 0 2 false
242
+ 1 (null) (null)
243
+ 2 (null) (null)
244
+ 3 (null) (null)
245
+ TABLE
246
+ end
247
+
150
248
  sub_test_case("wrong argument") do
151
249
  test("no arguments") do
152
250
  message = "wrong number of arguments (given 0, expected 1..2)"
@@ -190,20 +288,45 @@ class TableTest < Test::Unit::TestCase
190
288
  end
191
289
 
192
290
  sub_test_case("#[]") do
291
+ def setup
292
+ @table = Arrow::Table.new(a: [true],
293
+ b: [true],
294
+ c: [true],
295
+ d: [true],
296
+ e: [true],
297
+ f: [true],
298
+ g: [true])
299
+ end
300
+
193
301
  test("[String]") do
194
302
  assert_equal(Arrow::Column.new(@table, 0),
195
- @table["count"])
303
+ @table["a"])
196
304
  end
197
305
 
198
306
  test("[Symbol]") do
199
307
  assert_equal(Arrow::Column.new(@table, 1),
200
- @table[:visible])
308
+ @table[:b])
201
309
  end
202
310
 
203
311
  test("[Integer]") do
204
- assert_equal(Arrow::Column.new(@table, 1),
312
+ assert_equal(Arrow::Column.new(@table, 6),
205
313
  @table[-1])
206
314
  end
315
+
316
+ test("[Range]") do
317
+ assert_equal(Arrow::Table.new(d: [true],
318
+ e: [true]),
319
+ @table[3..4])
320
+ end
321
+
322
+ test("[[Symbol, String, Integer, Range]]") do
323
+ assert_equal(Arrow::Table.new(c: [true],
324
+ a: [true],
325
+ g: [true],
326
+ d: [true],
327
+ e: [true]),
328
+ @table[[:c, "a", -1, 3..4]])
329
+ end
207
330
  end
208
331
 
209
332
  sub_test_case("#merge") do
@@ -214,12 +337,12 @@ class TableTest < Test::Unit::TestCase
214
337
  count visible name
215
338
  0 1 true a
216
339
  1 2 false b
217
- 2 4 c
340
+ 2 4 (null) c
218
341
  3 8 true d
219
342
  4 16 true e
220
343
  5 32 false f
221
- 6 64 g
222
- 7 128 h
344
+ 6 64 (null) g
345
+ 7 128 (null) h
223
346
  TABLE
224
347
  end
225
348
 
@@ -261,12 +384,12 @@ class TableTest < Test::Unit::TestCase
261
384
  count visible name
262
385
  0 1 true a
263
386
  1 2 false b
264
- 2 4 c
387
+ 2 4 (null) c
265
388
  3 8 true d
266
389
  4 16 true e
267
390
  5 32 false f
268
- 6 64 g
269
- 7 128 h
391
+ 6 64 (null) g
392
+ 7 128 (null) h
270
393
  TABLE
271
394
  end
272
395
 
@@ -450,14 +573,20 @@ class TableTest < Test::Unit::TestCase
450
573
  assert_equal(@table, Arrow::Table.load(output, format: :batch))
451
574
  end
452
575
 
576
+ def test_arrows
577
+ output = create_output(".arrows")
578
+ @table.save(output, format: :arrows)
579
+ assert_equal(@table, Arrow::Table.load(output, format: :arrows))
580
+ end
581
+
453
582
  def test_arrow_streaming
454
- output = create_output(".arrow")
583
+ output = create_output(".arrows")
455
584
  @table.save(output, format: :arrow_streaming)
456
585
  assert_equal(@table, Arrow::Table.load(output, format: :arrow_streaming))
457
586
  end
458
587
 
459
588
  def test_stream
460
- output = create_output(".arrow")
589
+ output = create_output(".arrows")
461
590
  @table.save(output, format: :stream)
462
591
  assert_equal(@table, Arrow::Table.load(output, format: :stream))
463
592
  end
@@ -503,6 +632,24 @@ class TableTest < Test::Unit::TestCase
503
632
  end
504
633
 
505
634
  sub_test_case("save: auto detect") do
635
+ test("arrow") do
636
+ output = create_output(".arrow")
637
+ @table.save(output)
638
+ assert_equal(@table,
639
+ Arrow::Table.load(output,
640
+ format: :arrow,
641
+ schema: @table.schema))
642
+ end
643
+
644
+ test("arrows") do
645
+ output = create_output(".arrows")
646
+ @table.save(output)
647
+ assert_equal(@table,
648
+ Arrow::Table.load(output,
649
+ format: :arrows,
650
+ schema: @table.schema))
651
+ end
652
+
506
653
  test("csv") do
507
654
  output = create_output(".csv")
508
655
  @table.save(output)
@@ -541,7 +688,13 @@ class TableTest < Test::Unit::TestCase
541
688
 
542
689
  test("arrow: streaming") do
543
690
  output = create_output(".arrow")
544
- @table.save(output, format: :arrow_streaming)
691
+ @table.save(output, format: :arrows)
692
+ assert_equal(@table, Arrow::Table.load(output))
693
+ end
694
+
695
+ test("arrows") do
696
+ output = create_output(".arrows")
697
+ @table.save(output, format: :arrows)
545
698
  assert_equal(@table, Arrow::Table.load(output))
546
699
  end
547
700
 
@@ -605,6 +758,47 @@ chris\t-1
605
758
  end
606
759
  end
607
760
  end
761
+
762
+ sub_test_case("URI") do
763
+ def start_web_server(path, data, content_type)
764
+ http_server = WEBrick::HTTPServer.new(:Port => 0)
765
+ http_server.mount_proc(path) do |request, response|
766
+ response.body = data
767
+ response.content_type = content_type
768
+ end
769
+ http_server_thread = Thread.new do
770
+ http_server.start
771
+ end
772
+ begin
773
+ Timeout.timeout(1) do
774
+ yield(http_server[:Port])
775
+ end
776
+ ensure
777
+ http_server.shutdown
778
+ http_server_thread.join
779
+ end
780
+ end
781
+
782
+ data("Arrow File",
783
+ ["arrow", "application/vnd.apache.arrow.file"])
784
+ data("Arrow Stream",
785
+ ["arrows", "application/vnd.apache.arrow.stream"])
786
+ data("CSV",
787
+ ["csv", "text/csv"])
788
+ def test_http(data)
789
+ extension, content_type = data
790
+ output = Arrow::ResizableBuffer.new(1024)
791
+ @table.save(output, format: extension.to_sym)
792
+ path = "/data.#{extension}"
793
+ start_web_server(path,
794
+ output.data.to_s,
795
+ content_type) do |port|
796
+ input = URI("http://127.0.0.1:#{port}#{path}")
797
+ loaded_table = Arrow::Table.load(input)
798
+ assert_equal(@table.to_s, loaded_table.to_s)
799
+ end
800
+ end
801
+ end
608
802
  end
609
803
 
610
804
  test("#pack") do
@@ -614,12 +808,12 @@ chris\t-1
614
808
  count visible
615
809
  0 1 true
616
810
  1 2 false
617
- 2 4
811
+ 2 4 (null)
618
812
  3 8 true
619
813
  4 16 true
620
814
  5 32 false
621
- 6 64
622
- 7 128
815
+ 6 64 (null)
816
+ 7 128 (null)
623
817
  TABLE
624
818
  end
625
819
 
@@ -707,13 +901,13 @@ visible: false
707
901
  test("Array: boolean") do
708
902
  filter = [nil, true, true, false, true, false, true, true]
709
903
  assert_equal(<<-TABLE, @table.filter(filter, @options).to_s)
710
- count visible
711
- 0
712
- 1 2 false
713
- 2 4
714
- 3 16 true
715
- 4 64
716
- 5 128
904
+ count visible
905
+ 0 (null) (null)
906
+ 1 2 false
907
+ 2 4 (null)
908
+ 3 16 true
909
+ 4 64 (null)
910
+ 5 128 (null)
717
911
  TABLE
718
912
  end
719
913
 
@@ -721,13 +915,13 @@ visible: false
721
915
  array = [nil, true, true, false, true, false, true, true]
722
916
  filter = Arrow::BooleanArray.new(array)
723
917
  assert_equal(<<-TABLE, @table.filter(filter, @options).to_s)
724
- count visible
725
- 0
726
- 1 2 false
727
- 2 4
728
- 3 16 true
729
- 4 64
730
- 5 128
918
+ count visible
919
+ 0 (null) (null)
920
+ 1 2 false
921
+ 2 4 (null)
922
+ 3 16 true
923
+ 4 64 (null)
924
+ 5 128 (null)
731
925
  TABLE
732
926
  end
733
927
 
@@ -739,13 +933,13 @@ visible: false
739
933
  ]
740
934
  filter = Arrow::ChunkedArray.new(filter_chunks)
741
935
  assert_equal(<<-TABLE, @table.filter(filter, @options).to_s)
742
- count visible
743
- 0
744
- 1 2 false
745
- 2 4
746
- 3 16 true
747
- 4 64
748
- 5 128
936
+ count visible
937
+ 0 (null) (null)
938
+ 1 2 false
939
+ 2 4 (null)
940
+ 3 16 true
941
+ 4 64 (null)
942
+ 5 128 (null)
749
943
  TABLE
750
944
  end
751
945
  end
@@ -757,7 +951,7 @@ visible: false
757
951
  count visible
758
952
  0 2 false
759
953
  1 1 true
760
- 2 4
954
+ 2 4 (null)
761
955
  TABLE
762
956
  end
763
957
 
@@ -767,7 +961,7 @@ visible: false
767
961
  count visible
768
962
  0 2 false
769
963
  1 1 true
770
- 2 4
964
+ 2 4 (null)
771
965
  TABLE
772
966
  end
773
967
 
@@ -781,8 +975,134 @@ visible: false
781
975
  count visible
782
976
  0 2 false
783
977
  1 1 true
784
- 2 4
978
+ 2 4 (null)
785
979
  TABLE
786
980
  end
787
981
  end
982
+
983
+ sub_test_case("#concatenate") do
984
+ test("options: :unify_schemas") do
985
+ table1 = Arrow::Table.new(a: [true],
986
+ b: [false])
987
+ table2 = Arrow::Table.new(b: [false])
988
+ concatenated = table1.concatenate([table2], unify_schemas: true)
989
+ assert_equal(<<-TABLE, concatenated.to_s)
990
+ a b
991
+ 0 true false
992
+ 1 (null) false
993
+ TABLE
994
+ end
995
+ end
996
+
997
+ sub_test_case("#join") do
998
+ test("keys: String") do
999
+ table1 = Arrow::Table.new(key: [1, 2, 3],
1000
+ number: [10, 20, 30])
1001
+ table2 = Arrow::Table.new(key: [3, 1],
1002
+ string: ["three", "one"])
1003
+ assert_equal(Arrow::Table.new([
1004
+ ["key", [1, 3]],
1005
+ ["number", [10, 30]],
1006
+ ["key", [1, 3]],
1007
+ ["string", ["one", "three"]],
1008
+ ]),
1009
+ table1.join(table2, "key"))
1010
+ end
1011
+
1012
+ test("keys: Symbol") do
1013
+ table1 = Arrow::Table.new(key: [1, 2, 3],
1014
+ number: [10, 20, 30])
1015
+ table2 = Arrow::Table.new(key: [3, 1],
1016
+ string: ["three", "one"])
1017
+ assert_equal(Arrow::Table.new([
1018
+ ["key", [1, 3]],
1019
+ ["number", [10, 30]],
1020
+ ["key", [1, 3]],
1021
+ ["string", ["one", "three"]],
1022
+ ]),
1023
+ table1.join(table2, :key))
1024
+ end
1025
+
1026
+ test("keys: [String, Symbol]") do
1027
+ table1 = Arrow::Table.new(key1: [1, 1, 2, 2],
1028
+ key2: [10, 100, 20, 200],
1029
+ number: [1010, 1100, 2020, 2200])
1030
+ table2 = Arrow::Table.new(key1: [1, 2, 2],
1031
+ key2: [100, 20, 50],
1032
+ string: ["1-100", "2-20", "2-50"])
1033
+ assert_equal(Arrow::Table.new([
1034
+ ["key1", [1, 2]],
1035
+ ["key2", [100, 20]],
1036
+ ["number", [1100, 2020]],
1037
+ ["key1", [1, 2]],
1038
+ ["key2", [100, 20]],
1039
+ ["string", ["1-100", "2-20"]],
1040
+ ]),
1041
+ table1.join(table2, ["key1", :key2]))
1042
+ end
1043
+
1044
+ test("keys: {left: String, right: Symbol}") do
1045
+ table1 = Arrow::Table.new(left_key: [1, 2, 3],
1046
+ number: [10, 20, 30])
1047
+ table2 = Arrow::Table.new(right_key: [3, 1],
1048
+ string: ["three", "one"])
1049
+ assert_equal(Arrow::Table.new([
1050
+ ["left_key", [1, 3]],
1051
+ ["number", [10, 30]],
1052
+ ["right_key", [1, 3]],
1053
+ ["string", ["one", "three"]],
1054
+ ]),
1055
+ table1.join(table2, {left: "left_key", right: :right_key}))
1056
+ end
1057
+
1058
+ test("keys: {left: [String, Symbol], right: [Symbol, String]}") do
1059
+ table1 = Arrow::Table.new(left_key1: [1, 1, 2, 2],
1060
+ left_key2: [10, 100, 20, 200],
1061
+ number: [1010, 1100, 2020, 2200])
1062
+ table2 = Arrow::Table.new(right_key1: [1, 2, 2],
1063
+ right_key2: [100, 20, 50],
1064
+ string: ["1-100", "2-20", "2-50"])
1065
+ assert_equal(Arrow::Table.new([
1066
+ ["left_key1", [1, 2]],
1067
+ ["left_key2", [100, 20]],
1068
+ ["number", [1100, 2020]],
1069
+ ["right_key1", [1, 2]],
1070
+ ["right_key2", [100, 20]],
1071
+ ["string", ["1-100", "2-20"]],
1072
+ ]),
1073
+ table1.join(table2,
1074
+ {
1075
+ left: ["left_key1", :left_key2],
1076
+ right: [:right_key1, "right_key2"],
1077
+ }))
1078
+ end
1079
+
1080
+ test("type:") do
1081
+ table1 = Arrow::Table.new(key: [1, 2, 3],
1082
+ number: [10, 20, 30])
1083
+ table2 = Arrow::Table.new(key: [3, 1],
1084
+ string: ["three", "one"])
1085
+ assert_equal(Arrow::Table.new([
1086
+ ["key", [1, 3, 2]],
1087
+ ["number", [10, 30, 20]],
1088
+ ["key", [1, 3, nil]],
1089
+ ["string", ["one", "three", nil]],
1090
+ ]),
1091
+ table1.join(table2, "key", type: :left_outer))
1092
+ end
1093
+
1094
+ test("left_outputs: & right_outputs:") do
1095
+ table1 = Arrow::Table.new(key: [1, 2, 3],
1096
+ number: [10, 20, 30])
1097
+ table2 = Arrow::Table.new(key: [3, 1],
1098
+ string: ["three", "one"])
1099
+ assert_equal(Arrow::Table.new(key: [1, 3],
1100
+ number: [10, 30],
1101
+ string: ["one", "three"]),
1102
+ table1.join(table2,
1103
+ "key",
1104
+ left_outputs: ["key", "number"],
1105
+ right_outputs: ["string"]))
1106
+ end
1107
+ end
788
1108
  end
@@ -382,6 +382,20 @@ module ValuesDenseUnionArrayTests
382
382
  assert_equal(values, target.values)
383
383
  end
384
384
 
385
+ def test_map
386
+ values = [
387
+ {"0" => {"key1" => true, "key2" => nil}},
388
+ {"1" => nil},
389
+ ]
390
+ target = build({
391
+ type: :map,
392
+ key: :string,
393
+ item: :boolean,
394
+ },
395
+ values)
396
+ assert_equal(values, target.values)
397
+ end
398
+
385
399
  def test_sparse_union
386
400
  omit("Need to add support for SparseUnionArrayBuilder")
387
401
  values = [
@@ -420,6 +420,23 @@ module ValuesListArrayTests
420
420
  assert_equal(values, target.values)
421
421
  end
422
422
 
423
+ def test_map
424
+ values = [
425
+ [
426
+ {"key1" => true, "key2" => nil},
427
+ nil,
428
+ ],
429
+ nil,
430
+ ]
431
+ target = build({
432
+ type: :map,
433
+ key: :string,
434
+ item: :boolean,
435
+ },
436
+ values)
437
+ assert_equal(values, target.values)
438
+ end
439
+
423
440
  def test_sparse
424
441
  omit("Need to add support for SparseUnionArrayBuilder")
425
442
  values = [