red-arrow 10.0.0 → 16.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/ext/arrow/arrow.cpp +31 -0
- data/ext/arrow/converters.hpp +45 -41
- data/ext/arrow/extconf.rb +16 -4
- data/ext/arrow/raw-records.cpp +155 -2
- data/ext/arrow/red-arrow.hpp +2 -0
- data/ext/arrow/values.cpp +1 -2
- data/lib/arrow/array-computable.rb +13 -0
- data/lib/arrow/array.rb +6 -1
- data/lib/arrow/chunked-array.rb +35 -1
- data/lib/arrow/column-containable.rb +9 -0
- data/lib/arrow/column.rb +1 -0
- data/lib/arrow/data-type.rb +9 -0
- data/lib/arrow/dense-union-array-builder.rb +49 -0
- data/lib/arrow/dense-union-array.rb +26 -0
- data/lib/arrow/expression.rb +6 -2
- data/lib/arrow/function.rb +0 -1
- data/lib/arrow/half-float-array-builder.rb +32 -0
- data/lib/arrow/half-float-array.rb +24 -0
- data/lib/arrow/half-float.rb +118 -0
- data/lib/arrow/input-referable.rb +29 -0
- data/lib/arrow/loader.rb +11 -0
- data/lib/arrow/raw-table-converter.rb +7 -5
- data/lib/arrow/record-batch-file-reader.rb +2 -0
- data/lib/arrow/record-batch-stream-reader.rb +2 -0
- data/lib/arrow/record-batch.rb +6 -2
- data/lib/arrow/scalar.rb +67 -0
- data/lib/arrow/slicer.rb +61 -0
- data/lib/arrow/sort-key.rb +3 -3
- data/lib/arrow/sparse-union-array-builder.rb +56 -0
- data/lib/arrow/sparse-union-array.rb +26 -0
- data/lib/arrow/struct-array-builder.rb +0 -5
- data/lib/arrow/table-loader.rb +11 -5
- data/lib/arrow/table-saver.rb +1 -0
- data/lib/arrow/table.rb +180 -33
- data/lib/arrow/tensor.rb +4 -0
- data/lib/arrow/timestamp-parser.rb +33 -0
- data/lib/arrow/union-array-builder.rb +59 -0
- data/lib/arrow/version.rb +1 -1
- data/red-arrow.gemspec +2 -1
- data/test/each-raw-record/test-basic-arrays.rb +411 -0
- data/test/each-raw-record/test-dense-union-array.rb +566 -0
- data/test/each-raw-record/test-dictionary-array.rb +341 -0
- data/test/each-raw-record/test-list-array.rb +628 -0
- data/test/each-raw-record/test-map-array.rb +507 -0
- data/test/each-raw-record/test-multiple-columns.rb +72 -0
- data/test/each-raw-record/test-sparse-union-array.rb +528 -0
- data/test/each-raw-record/test-struct-array.rb +529 -0
- data/test/each-raw-record/test-table.rb +47 -0
- data/test/helper/omittable.rb +13 -0
- data/test/helper.rb +1 -0
- data/test/raw-records/test-basic-arrays.rb +11 -1
- data/test/raw-records/test-dense-union-array.rb +90 -45
- data/test/raw-records/test-list-array.rb +28 -10
- data/test/raw-records/test-map-array.rb +39 -10
- data/test/raw-records/test-sparse-union-array.rb +86 -41
- data/test/raw-records/test-struct-array.rb +22 -8
- data/test/test-array.rb +7 -0
- data/test/test-chunked-array.rb +9 -0
- data/test/test-csv-loader.rb +39 -0
- data/test/test-data-type.rb +2 -1
- data/test/test-dense-union-array.rb +42 -0
- data/test/test-dense-union-data-type.rb +1 -1
- data/test/test-expression.rb +11 -0
- data/test/test-function.rb +7 -7
- data/test/test-group.rb +58 -58
- data/test/test-half-float-array.rb +43 -0
- data/test/test-half-float.rb +130 -0
- data/test/test-ractor.rb +34 -0
- data/test/test-record-batch-file-reader.rb +21 -0
- data/test/test-record-batch-stream-reader.rb +129 -0
- data/test/test-scalar.rb +65 -0
- data/test/test-slicer.rb +194 -129
- data/test/test-sparse-union-array.rb +38 -0
- data/test/test-table.rb +356 -40
- data/test/values/test-basic-arrays.rb +10 -0
- data/test/values/test-dense-union-array.rb +88 -45
- data/test/values/test-list-array.rb +26 -10
- data/test/values/test-map-array.rb +33 -10
- data/test/values/test-sparse-union-array.rb +84 -41
- data/test/values/test-struct-array.rb +20 -8
- metadata +62 -9
data/test/test-table.rb
CHANGED
@@ -41,8 +41,25 @@ class TableTest < Test::Unit::TestCase
|
|
41
41
|
end
|
42
42
|
|
43
43
|
sub_test_case(".new") do
|
44
|
+
test("{Symbol: Arrow::Array}") do
|
45
|
+
schema = Arrow::Schema.new(numbers: :int64)
|
46
|
+
assert_equal(Arrow::Table.new(schema,
|
47
|
+
[Arrow::Int64Array.new([1, 2, 3])]),
|
48
|
+
Arrow::Table.new(numbers: Arrow::Int64Array.new([1, 2, 3])))
|
49
|
+
end
|
50
|
+
|
51
|
+
test("{Symbol: Arrow::ChunkedArray}") do
|
52
|
+
chunked_array = Arrow::ChunkedArray.new([Arrow::Int64Array.new([1, 2, 3])])
|
53
|
+
schema = Arrow::Schema.new(numbers: :int64)
|
54
|
+
assert_equal(Arrow::Table.new(schema,
|
55
|
+
[Arrow::Int64Array.new([1, 2, 3])]),
|
56
|
+
Arrow::Table.new(numbers: chunked_array))
|
57
|
+
end
|
58
|
+
|
44
59
|
test("{Symbol: Arrow::Tensor}") do
|
45
|
-
|
60
|
+
schema = Arrow::Schema.new(numbers: :uint8)
|
61
|
+
assert_equal(Arrow::Table.new(schema,
|
62
|
+
[Arrow::UInt8Array.new([1, 2, 3])]),
|
46
63
|
Arrow::Table.new(numbers: Arrow::Tensor.new([1, 2, 3])))
|
47
64
|
end
|
48
65
|
|
@@ -51,7 +68,8 @@ class TableTest < Test::Unit::TestCase
|
|
51
68
|
def array_like.to_ary
|
52
69
|
[1, 2, 3]
|
53
70
|
end
|
54
|
-
|
71
|
+
schema = Arrow::Schema.new(numbers: :uint8)
|
72
|
+
assert_equal(Arrow::Table.new(schema, [Arrow::UInt8Array.new([1, 2, 3])]),
|
55
73
|
Arrow::Table.new(numbers: array_like))
|
56
74
|
end
|
57
75
|
end
|
@@ -69,26 +87,24 @@ class TableTest < Test::Unit::TestCase
|
|
69
87
|
target_rows_raw = [nil, true, true, false, true, false, true, true]
|
70
88
|
target_rows = Arrow::BooleanArray.new(target_rows_raw)
|
71
89
|
assert_equal(<<-TABLE, @table.slice(target_rows).to_s)
|
72
|
-
|
73
|
-
0
|
74
|
-
1
|
75
|
-
2
|
76
|
-
3
|
77
|
-
4
|
78
|
-
5 128 (null)
|
90
|
+
count visible
|
91
|
+
0 2 false
|
92
|
+
1 4 (null)
|
93
|
+
2 16 true
|
94
|
+
3 64 (null)
|
95
|
+
4 128 (null)
|
79
96
|
TABLE
|
80
97
|
end
|
81
98
|
|
82
99
|
test("Array: boolean") do
|
83
100
|
target_rows_raw = [nil, true, true, false, true, false, true, true]
|
84
101
|
assert_equal(<<-TABLE, @table.slice(target_rows_raw).to_s)
|
85
|
-
|
86
|
-
0
|
87
|
-
1
|
88
|
-
2
|
89
|
-
3
|
90
|
-
4
|
91
|
-
5 128 (null)
|
102
|
+
count visible
|
103
|
+
0 2 false
|
104
|
+
1 4 (null)
|
105
|
+
2 16 true
|
106
|
+
3 64 (null)
|
107
|
+
4 128 (null)
|
92
108
|
TABLE
|
93
109
|
end
|
94
110
|
|
@@ -180,24 +196,18 @@ class TableTest < Test::Unit::TestCase
|
|
180
196
|
|
181
197
|
test("{key: true}") do
|
182
198
|
assert_equal(<<-TABLE, @table.slice(visible: true).to_s)
|
183
|
-
|
184
|
-
0
|
185
|
-
1
|
186
|
-
2
|
187
|
-
3 16 true
|
188
|
-
4 (null) (null)
|
189
|
-
5 (null) (null)
|
199
|
+
count visible
|
200
|
+
0 1 true
|
201
|
+
1 8 true
|
202
|
+
2 16 true
|
190
203
|
TABLE
|
191
204
|
end
|
192
205
|
|
193
206
|
test("{key: false}") do
|
194
207
|
assert_equal(<<-TABLE, @table.slice(visible: false).to_s)
|
195
|
-
|
196
|
-
0
|
197
|
-
1
|
198
|
-
2 32 false
|
199
|
-
3 (null) (null)
|
200
|
-
4 (null) (null)
|
208
|
+
count visible
|
209
|
+
0 2 false
|
210
|
+
1 32 false
|
201
211
|
TABLE
|
202
212
|
end
|
203
213
|
|
@@ -268,11 +278,8 @@ class TableTest < Test::Unit::TestCase
|
|
268
278
|
|
269
279
|
test("{key1: Range, key2: true}") do
|
270
280
|
assert_equal(<<-TABLE, @table.slice(count: 0..8, visible: false).to_s)
|
271
|
-
|
272
|
-
0
|
273
|
-
1 (null) (null)
|
274
|
-
2 (null) (null)
|
275
|
-
3 (null) (null)
|
281
|
+
count visible
|
282
|
+
0 2 false
|
276
283
|
TABLE
|
277
284
|
end
|
278
285
|
|
@@ -582,6 +589,25 @@ class TableTest < Test::Unit::TestCase
|
|
582
589
|
0 1
|
583
590
|
TABLE
|
584
591
|
end
|
592
|
+
|
593
|
+
test("empty result") do
|
594
|
+
selected_table = @table.filter([false] * @table.size).select_columns(:a)
|
595
|
+
assert_equal(<<-TABLE, selected_table.to_s)
|
596
|
+
a
|
597
|
+
TABLE
|
598
|
+
end
|
599
|
+
end
|
600
|
+
|
601
|
+
sub_test_case("#column_names") do
|
602
|
+
test("unique") do
|
603
|
+
table = Arrow::Table.new(a: [1], b: [2], c: [3])
|
604
|
+
assert_equal(%w[a b c], table.column_names)
|
605
|
+
end
|
606
|
+
|
607
|
+
test("duplicated") do
|
608
|
+
table = Arrow::Table.new([["a", [1, 2, 3]], ["a", [4, 5, 6]]])
|
609
|
+
assert_equal(%w[a a], table.column_names)
|
610
|
+
end
|
585
611
|
end
|
586
612
|
|
587
613
|
sub_test_case("#save and .load") do
|
@@ -651,6 +677,31 @@ class TableTest < Test::Unit::TestCase
|
|
651
677
|
format: :tsv,
|
652
678
|
schema: @table.schema))
|
653
679
|
end
|
680
|
+
|
681
|
+
def test_json
|
682
|
+
output = create_output(".json")
|
683
|
+
# TODO: Implement this.
|
684
|
+
# @table.save(output, format: :json)
|
685
|
+
columns = ""
|
686
|
+
@table.each_record.each do |record|
|
687
|
+
column = {
|
688
|
+
"count" => record.count,
|
689
|
+
"visible" => record.visible,
|
690
|
+
}
|
691
|
+
columns << column.to_json
|
692
|
+
columns << "\n"
|
693
|
+
end
|
694
|
+
if output.is_a?(String)
|
695
|
+
File.write(output, columns)
|
696
|
+
else
|
697
|
+
output.resize(columns.bytesize)
|
698
|
+
output.set_data(0, columns)
|
699
|
+
end
|
700
|
+
assert_equal(@table,
|
701
|
+
Arrow::Table.load(output,
|
702
|
+
format: :json,
|
703
|
+
schema: @table.schema))
|
704
|
+
end
|
654
705
|
end
|
655
706
|
|
656
707
|
sub_test_case("path") do
|
@@ -690,6 +741,11 @@ class TableTest < Test::Unit::TestCase
|
|
690
741
|
schema: @table.schema))
|
691
742
|
end
|
692
743
|
|
744
|
+
test("csv, return value") do
|
745
|
+
output = create_output(".csv")
|
746
|
+
assert_equal(@table, @table.save(output))
|
747
|
+
end
|
748
|
+
|
693
749
|
test("csv.gz") do
|
694
750
|
output = create_output(".csv.gz")
|
695
751
|
@table.save(output)
|
@@ -830,6 +886,76 @@ chris\t-1
|
|
830
886
|
end
|
831
887
|
end
|
832
888
|
end
|
889
|
+
|
890
|
+
sub_test_case("GC") do
|
891
|
+
def setup
|
892
|
+
table = Arrow::Table.new(integer: [1, 2, 3],
|
893
|
+
string: ["a", "b", "c"])
|
894
|
+
@buffer = Arrow::ResizableBuffer.new(1024)
|
895
|
+
table.save(@buffer, format: :arrow)
|
896
|
+
@loaded_table = Arrow::Table.load(@buffer)
|
897
|
+
end
|
898
|
+
|
899
|
+
def test_chunked_array
|
900
|
+
chunked_array = @loaded_table[0].data
|
901
|
+
assert_equal(@buffer,
|
902
|
+
chunked_array.instance_variable_get(:@input).buffer)
|
903
|
+
end
|
904
|
+
|
905
|
+
def test_array
|
906
|
+
array = @loaded_table[0].data.chunks[0]
|
907
|
+
assert_equal(@buffer,
|
908
|
+
array.instance_variable_get(:@input).buffer)
|
909
|
+
end
|
910
|
+
|
911
|
+
def test_record_batch
|
912
|
+
record_batch = @loaded_table.each_record_batch.first
|
913
|
+
assert_equal(@buffer,
|
914
|
+
record_batch.instance_variable_get(:@input).buffer)
|
915
|
+
end
|
916
|
+
|
917
|
+
def test_record_batch_array
|
918
|
+
array = @loaded_table.each_record_batch.first[0].data
|
919
|
+
assert_equal(@buffer,
|
920
|
+
array.instance_variable_get(:@input).buffer)
|
921
|
+
end
|
922
|
+
|
923
|
+
def test_record_batch_table
|
924
|
+
table = @loaded_table.each_record_batch.first.to_table
|
925
|
+
assert_equal(@buffer,
|
926
|
+
table.instance_variable_get(:@input).buffer)
|
927
|
+
end
|
928
|
+
|
929
|
+
def test_slice
|
930
|
+
table = @loaded_table.slice(0..-1)
|
931
|
+
assert_equal(@buffer,
|
932
|
+
table.instance_variable_get(:@input).buffer)
|
933
|
+
end
|
934
|
+
|
935
|
+
def test_merge
|
936
|
+
table = @loaded_table.merge({})
|
937
|
+
assert_equal(@buffer,
|
938
|
+
table.instance_variable_get(:@input).buffer)
|
939
|
+
end
|
940
|
+
|
941
|
+
def test_remove_column
|
942
|
+
table = @loaded_table.remove_column(0)
|
943
|
+
assert_equal(@buffer,
|
944
|
+
table.instance_variable_get(:@input).buffer)
|
945
|
+
end
|
946
|
+
|
947
|
+
def test_pack
|
948
|
+
table = @loaded_table.pack
|
949
|
+
assert_equal(@buffer,
|
950
|
+
table.instance_variable_get(:@input).buffer)
|
951
|
+
end
|
952
|
+
|
953
|
+
def test_join
|
954
|
+
table = @loaded_table.join(@loaded_table, :integer)
|
955
|
+
assert_equal(@buffer,
|
956
|
+
table.instance_variable_get(:@input).buffer)
|
957
|
+
end
|
958
|
+
end
|
833
959
|
end
|
834
960
|
|
835
961
|
test("#pack") do
|
@@ -1026,7 +1152,7 @@ visible: false
|
|
1026
1152
|
end
|
1027
1153
|
|
1028
1154
|
sub_test_case("#join") do
|
1029
|
-
test("keys:
|
1155
|
+
test("keys: nil (natural join)") do
|
1030
1156
|
table1 = Arrow::Table.new(key: [1, 2, 3],
|
1031
1157
|
number: [10, 20, 30])
|
1032
1158
|
table2 = Arrow::Table.new(key: [3, 1],
|
@@ -1034,7 +1160,19 @@ visible: false
|
|
1034
1160
|
assert_equal(Arrow::Table.new([
|
1035
1161
|
["key", [1, 3]],
|
1036
1162
|
["number", [10, 30]],
|
1163
|
+
["string", ["one", "three"]],
|
1164
|
+
]),
|
1165
|
+
table1.join(table2))
|
1166
|
+
end
|
1167
|
+
|
1168
|
+
test("keys: String") do
|
1169
|
+
table1 = Arrow::Table.new(key: [1, 2, 3],
|
1170
|
+
number: [10, 20, 30])
|
1171
|
+
table2 = Arrow::Table.new(key: [3, 1],
|
1172
|
+
string: ["three", "one"])
|
1173
|
+
assert_equal(Arrow::Table.new([
|
1037
1174
|
["key", [1, 3]],
|
1175
|
+
["number", [10, 30]],
|
1038
1176
|
["string", ["one", "three"]],
|
1039
1177
|
]),
|
1040
1178
|
table1.join(table2, "key"))
|
@@ -1048,12 +1186,25 @@ visible: false
|
|
1048
1186
|
assert_equal(Arrow::Table.new([
|
1049
1187
|
["key", [1, 3]],
|
1050
1188
|
["number", [10, 30]],
|
1051
|
-
["key", [1, 3]],
|
1052
1189
|
["string", ["one", "three"]],
|
1053
1190
|
]),
|
1054
1191
|
table1.join(table2, :key))
|
1055
1192
|
end
|
1056
1193
|
|
1194
|
+
test("keys: [String]") do
|
1195
|
+
table1 = Arrow::Table.new(key: [1, 2, 3],
|
1196
|
+
number: [10, 20, 30])
|
1197
|
+
table2 = Arrow::Table.new(key: [3, 1],
|
1198
|
+
string: ["three", "one"])
|
1199
|
+
assert_equal(Arrow::Table.new([
|
1200
|
+
["key", [1, 3]],
|
1201
|
+
["number", [10, 30]],
|
1202
|
+
["key", [1, 3]],
|
1203
|
+
["string", ["one", "three"]],
|
1204
|
+
]),
|
1205
|
+
table1.join(table2, ["key"]))
|
1206
|
+
end
|
1207
|
+
|
1057
1208
|
test("keys: [String, Symbol]") do
|
1058
1209
|
table1 = Arrow::Table.new(key1: [1, 1, 2, 2],
|
1059
1210
|
key2: [10, 100, 20, 200],
|
@@ -1083,7 +1234,9 @@ visible: false
|
|
1083
1234
|
["right_key", [1, 3]],
|
1084
1235
|
["string", ["one", "three"]],
|
1085
1236
|
]),
|
1086
|
-
table1.join(table2,
|
1237
|
+
table1.join(table2,
|
1238
|
+
{left: "left_key", right: :right_key},
|
1239
|
+
type: :inner))
|
1087
1240
|
end
|
1088
1241
|
|
1089
1242
|
test("keys: {left: [String, Symbol], right: [Symbol, String]}") do
|
@@ -1105,10 +1258,11 @@ visible: false
|
|
1105
1258
|
{
|
1106
1259
|
left: ["left_key1", :left_key2],
|
1107
1260
|
right: [:right_key1, "right_key2"],
|
1108
|
-
}
|
1261
|
+
},
|
1262
|
+
type: :inner))
|
1109
1263
|
end
|
1110
1264
|
|
1111
|
-
test("type:") do
|
1265
|
+
test("type: :left_outer") do
|
1112
1266
|
table1 = Arrow::Table.new(key: [1, 2, 3],
|
1113
1267
|
number: [10, 20, 30])
|
1114
1268
|
table2 = Arrow::Table.new(key: [3, 1],
|
@@ -1116,12 +1270,85 @@ visible: false
|
|
1116
1270
|
assert_equal(Arrow::Table.new([
|
1117
1271
|
["key", [1, 3, 2]],
|
1118
1272
|
["number", [10, 30, 20]],
|
1119
|
-
["key", [1, 3, nil]],
|
1120
1273
|
["string", ["one", "three", nil]],
|
1121
1274
|
]),
|
1122
1275
|
table1.join(table2, "key", type: :left_outer))
|
1123
1276
|
end
|
1124
1277
|
|
1278
|
+
test("type: :right_outer") do
|
1279
|
+
table1 = Arrow::Table.new(key: [1, 2, 3],
|
1280
|
+
number: [10, 20, 30])
|
1281
|
+
table2 = Arrow::Table.new(key: [3, 1],
|
1282
|
+
string: ["three", "one"])
|
1283
|
+
assert_equal(Arrow::Table.new([
|
1284
|
+
["key", [1, 3]],
|
1285
|
+
["number", [10, 30]],
|
1286
|
+
["string", ["one", "three"]],
|
1287
|
+
]),
|
1288
|
+
table1.join(table2, "key", type: :right_outer))
|
1289
|
+
end
|
1290
|
+
|
1291
|
+
test("type: :full_outer") do
|
1292
|
+
table1 = Arrow::Table.new(key: [1, 2, 3],
|
1293
|
+
number: [10, 20, 30])
|
1294
|
+
table2 = Arrow::Table.new(key: [3, 1],
|
1295
|
+
string: ["three", "one"])
|
1296
|
+
assert_equal(Arrow::Table.new([
|
1297
|
+
["key", [1, 3, 2]],
|
1298
|
+
["number", [10, 30, 20]],
|
1299
|
+
["string", ["one", "three", nil]],
|
1300
|
+
]),
|
1301
|
+
table1.join(table2, "key", type: :full_outer))
|
1302
|
+
end
|
1303
|
+
|
1304
|
+
test("type: :left_semi") do
|
1305
|
+
table1 = Arrow::Table.new(key: [1, 2, 3],
|
1306
|
+
number: [10, 20, 30])
|
1307
|
+
table2 = Arrow::Table.new(key: [3, 1],
|
1308
|
+
string: ["three", "one"])
|
1309
|
+
assert_equal(Arrow::Table.new([
|
1310
|
+
["key", [1, 3]],
|
1311
|
+
["number", [10, 30]],
|
1312
|
+
]),
|
1313
|
+
table1.join(table2, "key", type: :left_semi))
|
1314
|
+
end
|
1315
|
+
|
1316
|
+
test("type: :right_semi") do
|
1317
|
+
table1 = Arrow::Table.new(key: [1, 2, 3],
|
1318
|
+
number: [10, 20, 30])
|
1319
|
+
table2 = Arrow::Table.new(key: [3, 1],
|
1320
|
+
string: ["three", "one"])
|
1321
|
+
assert_equal(Arrow::Table.new([
|
1322
|
+
["key", [3, 1]],
|
1323
|
+
["string", ["three", "one"]],
|
1324
|
+
]),
|
1325
|
+
table1.join(table2, "key", type: :right_semi))
|
1326
|
+
end
|
1327
|
+
|
1328
|
+
test("type: :left_anti") do
|
1329
|
+
table1 = Arrow::Table.new(key: [1, 2, 3],
|
1330
|
+
number: [10, 20, 30])
|
1331
|
+
table2 = Arrow::Table.new(key: [3, 1],
|
1332
|
+
string: ["three", "one"])
|
1333
|
+
assert_equal(Arrow::Table.new([
|
1334
|
+
["key", [2]],
|
1335
|
+
["number", [20]],
|
1336
|
+
]),
|
1337
|
+
table1.join(table2, "key", type: :left_anti))
|
1338
|
+
end
|
1339
|
+
|
1340
|
+
test("type: :right_anti") do
|
1341
|
+
table1 = Arrow::Table.new(key: [1, 2, 3],
|
1342
|
+
number: [10, 20, 30])
|
1343
|
+
table2 = Arrow::Table.new(key: [3, 1],
|
1344
|
+
string: ["three", "one"])
|
1345
|
+
assert_equal(Arrow::Table.new([
|
1346
|
+
["key", Arrow::ChunkedArray.new(:uint8)],
|
1347
|
+
["string", Arrow::ChunkedArray.new(:string)],
|
1348
|
+
]),
|
1349
|
+
table1.join(table2, "key", type: :right_anti))
|
1350
|
+
end
|
1351
|
+
|
1125
1352
|
test("left_outputs: & right_outputs:") do
|
1126
1353
|
table1 = Arrow::Table.new(key: [1, 2, 3],
|
1127
1354
|
number: [10, 20, 30])
|
@@ -1135,5 +1362,94 @@ visible: false
|
|
1135
1362
|
left_outputs: ["key", "number"],
|
1136
1363
|
right_outputs: ["string"]))
|
1137
1364
|
end
|
1365
|
+
|
1366
|
+
test("left_outputs: & type: :inner") do
|
1367
|
+
table1 = Arrow::Table.new(key: [1, 2, 3],
|
1368
|
+
number: [10, 20, 30])
|
1369
|
+
table2 = Arrow::Table.new(key: [3, 1],
|
1370
|
+
string: ["three", "one"])
|
1371
|
+
assert_equal(Arrow::Table.new([
|
1372
|
+
["key", [1, 3]],
|
1373
|
+
["number", [10, 30]],
|
1374
|
+
["key", [1, 3]],
|
1375
|
+
["string", ["one", "three"]]
|
1376
|
+
]),
|
1377
|
+
table1.join(table2,
|
1378
|
+
type: :inner,
|
1379
|
+
left_outputs: table1.column_names,
|
1380
|
+
right_outputs: table2.column_names))
|
1381
|
+
end
|
1382
|
+
|
1383
|
+
test("left_outputs: & type: :left_outer") do
|
1384
|
+
table1 = Arrow::Table.new(key: [1, 2, 3],
|
1385
|
+
number: [10, 20, 30])
|
1386
|
+
table2 = Arrow::Table.new(key: [3, 1],
|
1387
|
+
string: ["three", "one"])
|
1388
|
+
assert_equal(Arrow::Table.new([
|
1389
|
+
["key", [1, 3, 2]],
|
1390
|
+
["number", [10, 30, 20]],
|
1391
|
+
["key", [1, 3, nil]],
|
1392
|
+
["string", ["one", "three", nil]],
|
1393
|
+
]),
|
1394
|
+
table1.join(table2,
|
1395
|
+
type: :left_outer,
|
1396
|
+
left_outputs: table1.column_names,
|
1397
|
+
right_outputs: table2.column_names))
|
1398
|
+
end
|
1399
|
+
|
1400
|
+
test("left_outputs: & type: :right_outer") do
|
1401
|
+
table1 = Arrow::Table.new(key: [1, 2, 3],
|
1402
|
+
number: [10, 20, 30])
|
1403
|
+
table2 = Arrow::Table.new(key: [3, 1],
|
1404
|
+
string: ["three", "one"])
|
1405
|
+
assert_equal(Arrow::Table.new([
|
1406
|
+
["key", [1, 3]],
|
1407
|
+
["number", [10, 30]],
|
1408
|
+
["key", [1, 3]],
|
1409
|
+
["string", ["one", "three"]],
|
1410
|
+
]),
|
1411
|
+
table1.join(table2,
|
1412
|
+
type: :right_outer,
|
1413
|
+
left_outputs: table1.column_names,
|
1414
|
+
right_outputs: table2.column_names))
|
1415
|
+
end
|
1416
|
+
|
1417
|
+
test("left_outputs: & type: :full_outer") do
|
1418
|
+
table1 = Arrow::Table.new(key: [1, 2, 3],
|
1419
|
+
number: [10, 20, 30])
|
1420
|
+
table2 = Arrow::Table.new(key: [3, 1],
|
1421
|
+
string: ["three", "one"])
|
1422
|
+
assert_equal(Arrow::Table.new([
|
1423
|
+
["key", [1, 3, 2]],
|
1424
|
+
["number", [10, 30, 20]],
|
1425
|
+
["key", [1, 3, nil]],
|
1426
|
+
["string", ["one", "three", nil]],
|
1427
|
+
]),
|
1428
|
+
table1.join(table2,
|
1429
|
+
type: :full_outer,
|
1430
|
+
left_outputs: table1.column_names,
|
1431
|
+
right_outputs: table2.column_names))
|
1432
|
+
end
|
1433
|
+
|
1434
|
+
test("left_suffix: & keys: [String]") do
|
1435
|
+
table1 = Arrow::Table.new(key1: [1, 1, 2, 2],
|
1436
|
+
key2: [10, 100, 20, 200],
|
1437
|
+
number: [1010, 1100, 2020, 2200])
|
1438
|
+
table2 = Arrow::Table.new(key1: [1, 2, 2],
|
1439
|
+
key2: [100, 20, 50],
|
1440
|
+
string: ["1-100", "2-20", "2-50"])
|
1441
|
+
assert_equal(Arrow::Table.new([
|
1442
|
+
["key1_left", [1, 2]],
|
1443
|
+
["key2_left", [100, 20]],
|
1444
|
+
["number", [1100, 2020]],
|
1445
|
+
["key1_right", [1, 2]],
|
1446
|
+
["key2_right", [100, 20]],
|
1447
|
+
["string", ["1-100", "2-20"]],
|
1448
|
+
]),
|
1449
|
+
table1.join(table2,
|
1450
|
+
["key1", "key2"],
|
1451
|
+
left_suffix: "_left",
|
1452
|
+
right_suffix: "_right"))
|
1453
|
+
end
|
1138
1454
|
end
|
1139
1455
|
end
|
@@ -107,6 +107,16 @@ module ValuesBasicArraysTests
|
|
107
107
|
assert_equal(values, target.values)
|
108
108
|
end
|
109
109
|
|
110
|
+
def test_half_float
|
111
|
+
values = [
|
112
|
+
-1.5,
|
113
|
+
nil,
|
114
|
+
1.5,
|
115
|
+
]
|
116
|
+
target = build(Arrow::HalfFloatArray.new(values))
|
117
|
+
assert_equal(values, target.values)
|
118
|
+
end
|
119
|
+
|
110
120
|
def test_float
|
111
121
|
values = [
|
112
122
|
-1.0,
|