red-arrow 8.0.0 → 10.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/ext/arrow/converters.hpp +3 -0
  3. data/ext/arrow/extconf.rb +8 -4
  4. data/lib/arrow/array-builder.rb +40 -6
  5. data/lib/arrow/array-computable.rb +37 -0
  6. data/lib/arrow/array.rb +28 -0
  7. data/lib/arrow/chunked-array.rb +21 -0
  8. data/lib/arrow/column.rb +28 -0
  9. data/lib/arrow/data-type.rb +8 -3
  10. data/lib/arrow/decimal128-array-builder.rb +16 -6
  11. data/lib/arrow/decimal128.rb +14 -0
  12. data/lib/arrow/decimal256-array-builder.rb +16 -6
  13. data/lib/arrow/decimal256.rb +14 -0
  14. data/lib/arrow/field.rb +44 -3
  15. data/lib/arrow/list-data-type.rb +1 -6
  16. data/lib/arrow/loader.rb +3 -0
  17. data/lib/arrow/raw-table-converter.rb +6 -1
  18. data/lib/arrow/raw-tensor-converter.rb +89 -0
  19. data/lib/arrow/string-array-builder.rb +30 -0
  20. data/lib/arrow/tensor.rb +140 -0
  21. data/lib/arrow/time-unit.rb +31 -0
  22. data/lib/arrow/time32-array-builder.rb +2 -14
  23. data/lib/arrow/time32-data-type.rb +9 -38
  24. data/lib/arrow/time64-array-builder.rb +2 -14
  25. data/lib/arrow/time64-data-type.rb +9 -38
  26. data/lib/arrow/timestamp-array-builder.rb +2 -14
  27. data/lib/arrow/timestamp-data-type.rb +9 -34
  28. data/lib/arrow/version.rb +1 -1
  29. data/red-arrow.gemspec +1 -1
  30. data/test/raw-records/test-dictionary-array.rb +341 -0
  31. data/test/test-array-builder.rb +62 -0
  32. data/test/test-chunked-array.rb +6 -0
  33. data/test/test-column.rb +31 -0
  34. data/test/test-decimal128-array-builder.rb +14 -0
  35. data/test/test-decimal128-array.rb +5 -2
  36. data/test/test-decimal128.rb +26 -2
  37. data/test/test-decimal256-array-builder.rb +14 -0
  38. data/test/test-decimal256-array.rb +5 -2
  39. data/test/test-decimal256.rb +26 -2
  40. data/test/test-field.rb +26 -0
  41. data/test/test-orc.rb +2 -2
  42. data/test/test-table.rb +16 -0
  43. data/test/test-tensor.rb +243 -2
  44. data/test/values/test-dictionary-array.rb +30 -0
  45. metadata +15 -9
@@ -0,0 +1,341 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+ module RawRecordsDictionaryArrayTests
19
+ def build_record_batch(array)
20
+ dictionary = array.dictionary_encode
21
+ schema = Arrow::Schema.new(column: dictionary.value_data_type)
22
+ Arrow::RecordBatch.new(schema, array.length, [dictionary])
23
+ end
24
+
25
+ def test_null
26
+ records = [
27
+ [nil],
28
+ [nil],
29
+ [nil],
30
+ [nil],
31
+ ]
32
+ target = build(Arrow::NullArray.new(records.collect(&:first)))
33
+ assert_equal(records, target.raw_records)
34
+ end
35
+
36
+ def test_boolean
37
+ records = [
38
+ [true],
39
+ [nil],
40
+ [false],
41
+ ]
42
+ target = build(Arrow::BooleanArray.new(records.collect(&:first)))
43
+ assert_equal(records, target.raw_records)
44
+ end
45
+
46
+ def test_int8
47
+ records = [
48
+ [-(2 ** 7)],
49
+ [nil],
50
+ [(2 ** 7) - 1],
51
+ ]
52
+ target = build(Arrow::Int8Array.new(records.collect(&:first)))
53
+ assert_equal(records, target.raw_records)
54
+ end
55
+
56
+ def test_uint8
57
+ records = [
58
+ [0],
59
+ [nil],
60
+ [(2 ** 8) - 1],
61
+ ]
62
+ target = build(Arrow::UInt8Array.new(records.collect(&:first)))
63
+ assert_equal(records, target.raw_records)
64
+ end
65
+
66
+ def test_int16
67
+ records = [
68
+ [-(2 ** 15)],
69
+ [nil],
70
+ [(2 ** 15) - 1],
71
+ ]
72
+ target = build(Arrow::Int16Array.new(records.collect(&:first)))
73
+ assert_equal(records, target.raw_records)
74
+ end
75
+
76
+ def test_uint16
77
+ records = [
78
+ [0],
79
+ [nil],
80
+ [(2 ** 16) - 1],
81
+ ]
82
+ target = build(Arrow::UInt16Array.new(records.collect(&:first)))
83
+ assert_equal(records, target.raw_records)
84
+ end
85
+
86
+ def test_int32
87
+ records = [
88
+ [-(2 ** 31)],
89
+ [nil],
90
+ [(2 ** 31) - 1],
91
+ ]
92
+ target = build(Arrow::Int32Array.new(records.collect(&:first)))
93
+ assert_equal(records, target.raw_records)
94
+ end
95
+
96
+ def test_uint32
97
+ records = [
98
+ [0],
99
+ [nil],
100
+ [(2 ** 32) - 1],
101
+ ]
102
+ target = build(Arrow::UInt32Array.new(records.collect(&:first)))
103
+ assert_equal(records, target.raw_records)
104
+ end
105
+
106
+ def test_int64
107
+ records = [
108
+ [-(2 ** 63)],
109
+ [nil],
110
+ [(2 ** 63) - 1],
111
+ ]
112
+ target = build(Arrow::Int64Array.new(records.collect(&:first)))
113
+ assert_equal(records, target.raw_records)
114
+ end
115
+
116
+ def test_uint64
117
+ records = [
118
+ [0],
119
+ [nil],
120
+ [(2 ** 64) - 1],
121
+ ]
122
+ target = build(Arrow::UInt64Array.new(records.collect(&:first)))
123
+ assert_equal(records, target.raw_records)
124
+ end
125
+
126
+ def test_float
127
+ records = [
128
+ [-1.0],
129
+ [nil],
130
+ [1.0],
131
+ ]
132
+ target = build(Arrow::FloatArray.new(records.collect(&:first)))
133
+ assert_equal(records, target.raw_records)
134
+ end
135
+
136
+ def test_double
137
+ records = [
138
+ [-1.0],
139
+ [nil],
140
+ [1.0],
141
+ ]
142
+ target = build(Arrow::DoubleArray.new(records.collect(&:first)))
143
+ assert_equal(records, target.raw_records)
144
+ end
145
+
146
+ def test_binary
147
+ records = [
148
+ ["\x00".b],
149
+ [nil],
150
+ ["\xff".b],
151
+ ]
152
+ target = build(Arrow::BinaryArray.new(records.collect(&:first)))
153
+ assert_equal(records, target.raw_records)
154
+ end
155
+
156
+ def test_string
157
+ records = [
158
+ ["Ruby"],
159
+ [nil],
160
+ ["\u3042"], # U+3042 HIRAGANA LETTER A
161
+ ]
162
+ target = build(Arrow::StringArray.new(records.collect(&:first)))
163
+ assert_equal(records, target.raw_records)
164
+ end
165
+
166
+ def test_date32
167
+ records = [
168
+ [Date.new(1960, 1, 1)],
169
+ [nil],
170
+ [Date.new(2017, 8, 23)],
171
+ ]
172
+ target = build(Arrow::Date32Array.new(records.collect(&:first)))
173
+ assert_equal(records, target.raw_records)
174
+ end
175
+
176
+ def test_date64
177
+ records = [
178
+ [DateTime.new(1960, 1, 1, 2, 9, 30)],
179
+ [nil],
180
+ [DateTime.new(2017, 8, 23, 14, 57, 2)],
181
+ ]
182
+ target = build(Arrow::Date64Array.new(records.collect(&:first)))
183
+ assert_equal(records, target.raw_records)
184
+ end
185
+
186
+ def test_timestamp_second
187
+ records = [
188
+ [Time.parse("1960-01-01T02:09:30Z")],
189
+ [nil],
190
+ [Time.parse("2017-08-23T14:57:02Z")],
191
+ ]
192
+ target = build(Arrow::TimestampArray.new(:second, records.collect(&:first)))
193
+ assert_equal(records, target.raw_records)
194
+ end
195
+
196
+ def test_timestamp_milli
197
+ records = [
198
+ [Time.parse("1960-01-01T02:09:30.123Z")],
199
+ [nil],
200
+ [Time.parse("2017-08-23T14:57:02.987Z")],
201
+ ]
202
+ target = build(Arrow::TimestampArray.new(:milli, records.collect(&:first)))
203
+ assert_equal(records, target.raw_records)
204
+ end
205
+
206
+ def test_timestamp_micro
207
+ records = [
208
+ [Time.parse("1960-01-01T02:09:30.123456Z")],
209
+ [nil],
210
+ [Time.parse("2017-08-23T14:57:02.987654Z")],
211
+ ]
212
+ target = build(Arrow::TimestampArray.new(:micro, records.collect(&:first)))
213
+ assert_equal(records, target.raw_records)
214
+ end
215
+
216
+ def test_timestamp_nano
217
+ records = [
218
+ [Time.parse("1960-01-01T02:09:30.123456789Z")],
219
+ [nil],
220
+ [Time.parse("2017-08-23T14:57:02.987654321Z")],
221
+ ]
222
+ target = build(Arrow::TimestampArray.new(:nano, records.collect(&:first)))
223
+ assert_equal(records, target.raw_records)
224
+ end
225
+
226
+ def test_time32_second
227
+ unit = Arrow::TimeUnit::SECOND
228
+ records = [
229
+ [Arrow::Time.new(unit, 60 * 10)], # 00:10:00
230
+ [nil],
231
+ [Arrow::Time.new(unit, 60 * 60 * 2 + 9)], # 02:00:09
232
+ ]
233
+ target = build(Arrow::Time32Array.new(unit, records.collect(&:first)))
234
+ assert_equal(records, target.raw_records)
235
+ end
236
+
237
+ def test_time32_milli
238
+ unit = Arrow::TimeUnit::MILLI
239
+ records = [
240
+ [Arrow::Time.new(unit, (60 * 10) * 1000 + 123)], # 00:10:00.123
241
+ [nil],
242
+ [Arrow::Time.new(unit, (60 * 60 * 2 + 9) * 1000 + 987)], # 02:00:09.987
243
+ ]
244
+ target = build(Arrow::Time32Array.new(unit, records.collect(&:first)))
245
+ assert_equal(records, target.raw_records)
246
+ end
247
+
248
+ def test_time64_micro
249
+ unit = Arrow::TimeUnit::MICRO
250
+ records = [
251
+ # 00:10:00.123456
252
+ [Arrow::Time.new(unit, (60 * 10) * 1_000_000 + 123_456)],
253
+ [nil],
254
+ # 02:00:09.987654
255
+ [Arrow::Time.new(unit, (60 * 60 * 2 + 9) * 1_000_000 + 987_654)],
256
+ ]
257
+ target = build(Arrow::Time64Array.new(unit, records.collect(&:first)))
258
+ assert_equal(records, target.raw_records)
259
+ end
260
+
261
+ def test_time64_nano
262
+ unit = Arrow::TimeUnit::NANO
263
+ records = [
264
+ # 00:10:00.123456789
265
+ [Arrow::Time.new(unit, (60 * 10) * 1_000_000_000 + 123_456_789)],
266
+ [nil],
267
+ # 02:00:09.987654321
268
+ [Arrow::Time.new(unit, (60 * 60 * 2 + 9) * 1_000_000_000 + 987_654_321)],
269
+ ]
270
+ target = build(Arrow::Time64Array.new(unit, records.collect(&:first)))
271
+ assert_equal(records, target.raw_records)
272
+ end
273
+
274
+ def test_decimal128
275
+ records = [
276
+ [BigDecimal("92.92")],
277
+ [nil],
278
+ [BigDecimal("29.29")],
279
+ ]
280
+ data_type = Arrow::Decimal128DataType.new(8, 2)
281
+ target = build(Arrow::Decimal128Array.new(data_type, records.collect(&:first)))
282
+ assert_equal(records, target.raw_records)
283
+ end
284
+
285
+ def test_decimal256
286
+ records = [
287
+ [BigDecimal("92.92")],
288
+ [nil],
289
+ [BigDecimal("29.29")],
290
+ ]
291
+ data_type = Arrow::Decimal256DataType.new(38, 2)
292
+ target = build(Arrow::Decimal256Array.new(data_type, records.collect(&:first)))
293
+ assert_equal(records, target.raw_records)
294
+ end
295
+
296
+ def test_month_interval
297
+ records = [
298
+ [1],
299
+ [nil],
300
+ [12],
301
+ ]
302
+ target = build(Arrow::MonthIntervalArray.new(records.collect(&:first)))
303
+ assert_equal(records, target.raw_records)
304
+ end
305
+
306
+ def test_day_time_interval
307
+ records = [
308
+ [{day: 1, millisecond: 100}],
309
+ [nil],
310
+ [{day: 2, millisecond: 300}],
311
+ ]
312
+ target = build(Arrow::DayTimeIntervalArray.new(records.collect(&:first)))
313
+ assert_equal(records, target.raw_records)
314
+ end
315
+
316
+ def test_month_day_nano_interval
317
+ records = [
318
+ [{month: 1, day: 1, nanosecond: 100}],
319
+ [nil],
320
+ [{month: 2, day: 3, nanosecond: 400}],
321
+ ]
322
+ target = build(Arrow::MonthDayNanoIntervalArray.new(records.collect(&:first)))
323
+ assert_equal(records, target.raw_records)
324
+ end
325
+ end
326
+
327
+ class RawRecordsRecordBatchDictionaryArraysTest < Test::Unit::TestCase
328
+ include RawRecordsDictionaryArrayTests
329
+
330
+ def build(array)
331
+ build_record_batch(array)
332
+ end
333
+ end
334
+
335
+ class RawRecordsTableDictionaryArraysTest < Test::Unit::TestCase
336
+ include RawRecordsDictionaryArrayTests
337
+
338
+ def build(array)
339
+ build_record_batch(array).to_table
340
+ end
341
+ end
@@ -68,6 +68,68 @@ class ArrayBuilderTest < Test::Unit::TestCase
68
68
  ])
69
69
  end
70
70
 
71
+ test("decimal + string") do
72
+ raw_array = [BigDecimal("10.1"), "10.1"]
73
+ array = Arrow::ArrayBuilder.build(raw_array)
74
+ assert_equal(raw_array.collect(&:to_s), array.to_a)
75
+ end
76
+
77
+ test("NaN") do
78
+ raw_array = [BigDecimal("10.1"), BigDecimal::NAN]
79
+ array = Arrow::ArrayBuilder.build(raw_array)
80
+ assert_equal(raw_array.collect(&:to_s), array.to_a)
81
+ end
82
+
83
+ test("Infinity") do
84
+ raw_array = [BigDecimal("10.1"), BigDecimal::INFINITY]
85
+ array = Arrow::ArrayBuilder.build(raw_array)
86
+ assert_equal(raw_array.collect(&:to_s), array.to_a)
87
+ end
88
+
89
+ test("decimal128") do
90
+ values = [
91
+ BigDecimal("10.1"),
92
+ BigDecimal("1.11"),
93
+ BigDecimal("1"),
94
+ ]
95
+ array = Arrow::Array.new(values)
96
+ data_type = Arrow::Decimal128DataType.new(3, 2)
97
+ assert_equal({
98
+ data_type: data_type,
99
+ values: [
100
+ BigDecimal("10.1"),
101
+ BigDecimal("1.11"),
102
+ BigDecimal("1"),
103
+ ],
104
+ },
105
+ {
106
+ data_type: array.value_data_type,
107
+ values: array.to_a,
108
+ })
109
+ end
110
+
111
+ test("decimal256") do
112
+ values = [
113
+ BigDecimal("1" * 40 + ".1"),
114
+ BigDecimal("1" * 38 + ".11"),
115
+ BigDecimal("1" * 37),
116
+ ]
117
+ array = Arrow::Array.new(values)
118
+ data_type = Arrow::Decimal256DataType.new(41, 2)
119
+ assert_equal({
120
+ data_type: data_type,
121
+ values: [
122
+ BigDecimal("1" * 40 + ".1"),
123
+ BigDecimal("1" * 38 + ".11"),
124
+ BigDecimal("1" * 37),
125
+ ],
126
+ },
127
+ {
128
+ data_type: array.value_data_type,
129
+ values: array.to_a,
130
+ })
131
+ end
132
+
71
133
  test("list<boolean>s") do
72
134
  assert_build(Arrow::ArrayBuilder,
73
135
  [
@@ -180,4 +180,10 @@ class ChunkedArrayTest < Test::Unit::TestCase
180
180
  @chunked_array.take(indices))
181
181
  end
182
182
  end
183
+
184
+ test("#cast") do
185
+ chunked_array = Arrow::ChunkedArray.new([[1, nil, 3]])
186
+ assert_equal(Arrow::ChunkedArray.new([["1", nil, "3"]]),
187
+ chunked_array.cast(:string))
188
+ end
183
189
  end
data/test/test-column.rb CHANGED
@@ -89,4 +89,35 @@ class ColumnTest < Test::Unit::TestCase
89
89
  end
90
90
  end
91
91
  end
92
+
93
+ test("#count") do
94
+ table = Arrow::Table.new("revenue" => [1, nil, 3])
95
+ assert_equal(2, table["revenue"].count)
96
+ end
97
+
98
+ test("#min") do
99
+ table = Arrow::Table.new("revenue" => [1, 2, 3])
100
+ assert_equal(1, table["revenue"].min)
101
+ end
102
+
103
+ test("#max") do
104
+ table = Arrow::Table.new("revenue" => [1, 2, 3])
105
+ assert_equal(3, table["revenue"].max)
106
+ end
107
+
108
+ test("#sum") do
109
+ table = Arrow::Table.new("revenue" => [1, 2, 3])
110
+ assert_equal(6, table["revenue"].sum)
111
+ end
112
+
113
+ test("#uniq") do
114
+ table = Arrow::Table.new("revenue" => [1, 2, 2])
115
+ assert_equal([1, 2], table["revenue"].uniq)
116
+ end
117
+
118
+ test("#cast") do
119
+ table = Arrow::Table.new("revenue" => [1, nil, 3])
120
+ assert_equal(Arrow::ChunkedArray.new([["1", nil, "3"]]),
121
+ table["revenue"].cast(:string))
122
+ end
92
123
  end
@@ -55,6 +55,20 @@ class Decimal128ArrayBuilderTest < Test::Unit::TestCase
55
55
  assert_equal(BigDecimal("10.1"),
56
56
  array[0])
57
57
  end
58
+
59
+ test("BigDecimal::NAN") do
60
+ message = "can't use NaN as an Arrow::Decimal128Array value"
61
+ assert_raise(FloatDomainError.new(message)) do
62
+ @builder.append_value(BigDecimal::NAN)
63
+ end
64
+ end
65
+
66
+ test("BigDecimal::INFINITY") do
67
+ message = "can't use Infinity as an Arrow::Decimal128Array value"
68
+ assert_raise(FloatDomainError.new(message)) do
69
+ @builder.append_value(BigDecimal::INFINITY)
70
+ end
71
+ end
58
72
  end
59
73
 
60
74
  sub_test_case("#append_values") do
@@ -18,19 +18,22 @@
18
18
  class Decimal128ArrayTest < Test::Unit::TestCase
19
19
  sub_test_case(".new") do
20
20
  test("build") do
21
- data_type = Arrow::Decimal128DataType.new(3, 1)
22
21
  values = [
23
22
  10.1,
24
23
  nil,
25
24
  "10.1",
26
25
  BigDecimal("10.1"),
26
+ BigDecimal("1.11"),
27
+ BigDecimal("1"),
27
28
  ]
28
- array = Arrow::Decimal128Array.new(data_type, values)
29
+ array = Arrow::Decimal128Array.new({precision: 3, scale: 1}, values)
29
30
  assert_equal([
30
31
  BigDecimal("10.1"),
31
32
  nil,
32
33
  BigDecimal("10.1"),
33
34
  BigDecimal("10.1"),
35
+ BigDecimal("1.1"),
36
+ BigDecimal("1"),
34
37
  ],
35
38
  array.to_a)
36
39
  end
@@ -28,9 +28,21 @@ class Decimal128Test < Test::Unit::TestCase
28
28
  end
29
29
  end
30
30
 
31
+ test("String") do
32
+ assert do
33
+ @decimal128 == "10.1"
34
+ end
35
+ end
36
+
37
+ test("Float") do
38
+ assert do
39
+ @decimal128 == 10.1
40
+ end
41
+ end
42
+
31
43
  test("not Arrow::Decimal128") do
32
44
  assert do
33
- not (@decimal128 == 10.1)
45
+ not (@decimal128 == :"10.1")
34
46
  end
35
47
  end
36
48
  end
@@ -42,9 +54,21 @@ class Decimal128Test < Test::Unit::TestCase
42
54
  end
43
55
  end
44
56
 
57
+ test("String") do
58
+ assert do
59
+ not (@decimal128 != "10.1")
60
+ end
61
+ end
62
+
63
+ test("Float") do
64
+ assert do
65
+ not (@decimal128 != 10.1)
66
+ end
67
+ end
68
+
45
69
  test("not Arrow::Decimal128") do
46
70
  assert do
47
- @decimal128 != 10.1
71
+ @decimal128 != :"10.1"
48
72
  end
49
73
  end
50
74
  end
@@ -55,6 +55,20 @@ class Decimal256ArrayBuilderTest < Test::Unit::TestCase
55
55
  assert_equal(BigDecimal("10.1"),
56
56
  array[0])
57
57
  end
58
+
59
+ test("BigDecimal::NAN") do
60
+ message = "can't use NaN as an Arrow::Decimal256Array value"
61
+ assert_raise(FloatDomainError.new(message)) do
62
+ @builder.append_value(BigDecimal::NAN)
63
+ end
64
+ end
65
+
66
+ test("BigDecimal::INFINITY") do
67
+ message = "can't use Infinity as an Arrow::Decimal256Array value"
68
+ assert_raise(FloatDomainError.new(message)) do
69
+ @builder.append_value(BigDecimal::INFINITY)
70
+ end
71
+ end
58
72
  end
59
73
 
60
74
  sub_test_case("#append_values") do
@@ -18,19 +18,22 @@
18
18
  class Decimal256ArrayTest < Test::Unit::TestCase
19
19
  sub_test_case(".new") do
20
20
  test("build") do
21
- data_type = Arrow::Decimal256DataType.new(3, 1)
22
21
  values = [
23
22
  10.1,
24
23
  nil,
25
24
  "10.1",
26
25
  BigDecimal("10.1"),
26
+ BigDecimal("1.11"),
27
+ BigDecimal("1"),
27
28
  ]
28
- array = Arrow::Decimal256Array.new(data_type, values)
29
+ array = Arrow::Decimal256Array.new({precision: 3, scale: 1}, values)
29
30
  assert_equal([
30
31
  BigDecimal("10.1"),
31
32
  nil,
32
33
  BigDecimal("10.1"),
33
34
  BigDecimal("10.1"),
35
+ BigDecimal("1.1"),
36
+ BigDecimal("1"),
34
37
  ],
35
38
  array.to_a)
36
39
  end
@@ -28,9 +28,21 @@ class Decimal256Test < Test::Unit::TestCase
28
28
  end
29
29
  end
30
30
 
31
+ test("String") do
32
+ assert do
33
+ @decimal256 == "10.1"
34
+ end
35
+ end
36
+
37
+ test("Float") do
38
+ assert do
39
+ @decimal256 == 10.1
40
+ end
41
+ end
42
+
31
43
  test("not Arrow::Decimal256") do
32
44
  assert do
33
- not (@decimal256 == 10.1)
45
+ not (@decimal256 == :"10.1")
34
46
  end
35
47
  end
36
48
  end
@@ -42,9 +54,21 @@ class Decimal256Test < Test::Unit::TestCase
42
54
  end
43
55
  end
44
56
 
57
+ test("String") do
58
+ assert do
59
+ not (@decimal256 != "10.1")
60
+ end
61
+ end
62
+
63
+ test("Float") do
64
+ assert do
65
+ not (@decimal256 != 10.1)
66
+ end
67
+ end
68
+
45
69
  test("not Arrow::Decimal256") do
46
70
  assert do
47
- @decimal256 != 10.1
71
+ @decimal256 != :"10.1"
48
72
  end
49
73
  end
50
74
  end
data/test/test-field.rb CHANGED
@@ -22,6 +22,13 @@ class FieldTest < Test::Unit::TestCase
22
22
  Arrow::Field.new("visible", Arrow::BooleanDataType.new).to_s)
23
23
  end
24
24
 
25
+ test("String, Arrow::DataType, Boolean") do
26
+ assert_equal("visible: bool not null",
27
+ Arrow::Field.new("visible",
28
+ Arrow::BooleanDataType.new,
29
+ false).to_s)
30
+ end
31
+
25
32
  test("Symbol, Arrow::DataType") do
26
33
  assert_equal("visible: bool",
27
34
  Arrow::Field.new(:visible, Arrow::BooleanDataType.new).to_s)
@@ -37,6 +44,18 @@ class FieldTest < Test::Unit::TestCase
37
44
  Arrow::Field.new(:visible, type: :boolean).to_s)
38
45
  end
39
46
 
47
+ test("String, Hash (:nullable)") do
48
+ assert_equal("visible: bool not null",
49
+ Arrow::Field.new(:visible,
50
+ type: :boolean,
51
+ nullable: false).to_s)
52
+ end
53
+
54
+ test("String, Hash, Boolean)") do
55
+ assert_equal("visible: bool not null",
56
+ Arrow::Field.new(:visible, {type: :boolean}, false).to_s)
57
+ end
58
+
40
59
  test("description: String") do
41
60
  assert_equal("visible: bool",
42
61
  Arrow::Field.new(name: "visible",
@@ -55,6 +74,13 @@ class FieldTest < Test::Unit::TestCase
55
74
  type: :boolean).to_s)
56
75
  end
57
76
 
77
+ test("description: nullable") do
78
+ assert_equal("visible: bool not null",
79
+ Arrow::Field.new(name: :visible,
80
+ data_type: :boolean,
81
+ nullable: false).to_s)
82
+ end
83
+
58
84
  test("Hash: shortcut: additional") do
59
85
  description = {
60
86
  name: :tags,
data/test/test-orc.rb CHANGED
@@ -164,8 +164,8 @@ class ORCTest < Test::Unit::TestCase
164
164
  ]
165
165
  end
166
166
  assert_equal([
167
- ["boolean1: bool", [pp_values([false, true])]],
168
- ["short1: int16", [pp_values([1024, 2048])]],
167
+ ["byte1: int8", [pp_values([1, 100])]],
168
+ ["int1: int32", [pp_values([65536, 65536])]],
169
169
  ],
170
170
  dump)
171
171
  end