red-arrow 7.0.0 → 8.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cee7217ce22a2c2d7a20bbe073ffe41efbab3d9628cfdc0e19e077acb4965557
4
- data.tar.gz: da14c7fd57bf63294fbe46f74bb286b0d6e26dafaa80b977d11639c275dbd677
3
+ metadata.gz: f43d3875f2e48876cd47533124a9fcf9559e263e63e3954c65fedd36b4e59744
4
+ data.tar.gz: 2548f661536d3288f4ad8bb25d6587a78ee51d810a85a7d533ccdaf595439a12
5
5
  SHA512:
6
- metadata.gz: 52e22fdcc86f32f0443a6335099ce510840dfae9134bb4ffe6d51bfcbfdc2d66f87bbe29cd46a7af670077add2d12786474eaa3a716a27dc161fcd69b7c40974
7
- data.tar.gz: 23b84e6766953cc89e8502043065dfdcf0c6a83ef1f29feae2a85e6ec3f7e01f0800f975eeb38076b255688a818984b9ae5eca2da483b96e42c5dd132089355a
6
+ metadata.gz: caeffbc164f14db7b056263f1ecd449afe2feec3ccbf7b883c147d415199c9ddc6c20398b00c34884248c103fbb7c55aa225719d8b8e75ac7f49337ee89d557e
7
+ data.tar.gz: ae5a793e06b63bd80e3499f794193f47f72ff7510a558d2d0e61314068d5bd3a1986e5083bda749b00b73a4615901beb320521eeb360576b93fcb9a1e9d9510a
data/ext/arrow/arrow.cpp CHANGED
@@ -36,6 +36,13 @@ namespace red_arrow {
36
36
  ID id_jd;
37
37
  ID id_new;
38
38
  ID id_to_datetime;
39
+
40
+ namespace symbols {
41
+ VALUE day;
42
+ VALUE millisecond;
43
+ VALUE month;
44
+ VALUE nanosecond;
45
+ }
39
46
  }
40
47
 
41
48
  extern "C" void Init_arrow() {
@@ -81,4 +88,9 @@ extern "C" void Init_arrow() {
81
88
  red_arrow::id_to_datetime = rb_intern("to_datetime");
82
89
 
83
90
  red_arrow::memory_view::init(mArrow);
91
+
92
+ red_arrow::symbols::day = ID2SYM(rb_intern("day"));
93
+ red_arrow::symbols::millisecond = ID2SYM(rb_intern("millisecond"));
94
+ red_arrow::symbols::month = ID2SYM(rb_intern("month"));
95
+ red_arrow::symbols::nanosecond = ID2SYM(rb_intern("nanosecond"));
84
96
  }
@@ -202,6 +202,40 @@ namespace red_arrow {
202
202
  // const int64_t i) {
203
203
  // };
204
204
 
205
+ inline VALUE convert(const arrow::MonthIntervalArray& array,
206
+ const int64_t i) {
207
+ return INT2NUM(array.Value(i));
208
+ }
209
+
210
+ inline VALUE convert(const arrow::DayTimeIntervalArray& array,
211
+ const int64_t i) {
212
+ auto value = rb_hash_new();
213
+ auto arrow_value = array.Value(i);
214
+ rb_hash_aset(value,
215
+ red_arrow::symbols::day,
216
+ INT2NUM(arrow_value.days));
217
+ rb_hash_aset(value,
218
+ red_arrow::symbols::millisecond,
219
+ INT2NUM(arrow_value.milliseconds));
220
+ return value;
221
+ }
222
+
223
+ inline VALUE convert(const arrow::MonthDayNanoIntervalArray& array,
224
+ const int64_t i) {
225
+ auto value = rb_hash_new();
226
+ auto arrow_value = array.Value(i);
227
+ rb_hash_aset(value,
228
+ red_arrow::symbols::month,
229
+ INT2NUM(arrow_value.months));
230
+ rb_hash_aset(value,
231
+ red_arrow::symbols::day,
232
+ INT2NUM(arrow_value.days));
233
+ rb_hash_aset(value,
234
+ red_arrow::symbols::nanosecond,
235
+ INT2NUM(arrow_value.nanoseconds));
236
+ return value;
237
+ }
238
+
205
239
  VALUE convert(const arrow::ListArray& array,
206
240
  const int64_t i);
207
241
 
@@ -298,8 +332,9 @@ namespace red_arrow {
298
332
  VISIT(Time32)
299
333
  VISIT(Time64)
300
334
  VISIT(Timestamp)
301
- // TODO
302
- // VISIT(Interval)
335
+ VISIT(MonthInterval)
336
+ VISIT(DayTimeInterval)
337
+ VISIT(MonthDayNanoInterval)
303
338
  VISIT(List)
304
339
  VISIT(Struct)
305
340
  VISIT(Map)
@@ -404,8 +439,9 @@ namespace red_arrow {
404
439
  VISIT(Time32)
405
440
  VISIT(Time64)
406
441
  VISIT(Timestamp)
407
- // TODO
408
- // VISIT(Interval)
442
+ VISIT(MonthInterval)
443
+ VISIT(DayTimeInterval)
444
+ VISIT(MonthDayNanoInterval)
409
445
  VISIT(List)
410
446
  VISIT(Struct)
411
447
  VISIT(Map)
@@ -506,8 +542,9 @@ namespace red_arrow {
506
542
  VISIT(Time32)
507
543
  VISIT(Time64)
508
544
  VISIT(Timestamp)
509
- // TODO
510
- // VISIT(Interval)
545
+ VISIT(MonthInterval)
546
+ VISIT(DayTimeInterval)
547
+ VISIT(MonthDayNanoInterval)
511
548
  VISIT(List)
512
549
  VISIT(Struct)
513
550
  VISIT(Map)
@@ -609,8 +646,9 @@ namespace red_arrow {
609
646
  VISIT(Time32)
610
647
  VISIT(Time64)
611
648
  VISIT(Timestamp)
612
- // TODO
613
- // VISIT(Interval)
649
+ VISIT(MonthInterval)
650
+ VISIT(DayTimeInterval)
651
+ VISIT(MonthDayNanoInterval)
614
652
  VISIT(List)
615
653
  VISIT(Struct)
616
654
  VISIT(Map)
@@ -735,8 +773,6 @@ namespace red_arrow {
735
773
  VISIT(Time32)
736
774
  VISIT(Time64)
737
775
  VISIT(Timestamp)
738
- // TODO
739
- // VISIT(Interval)
740
776
  VISIT(List)
741
777
  VISIT(Struct)
742
778
  VISIT(Map)
@@ -96,8 +96,9 @@ namespace red_arrow {
96
96
  VISIT(Time32)
97
97
  VISIT(Time64)
98
98
  VISIT(Timestamp)
99
- // TODO
100
- // VISIT(Interval)
99
+ VISIT(MonthInterval)
100
+ VISIT(DayTimeInterval)
101
+ VISIT(MonthDayNanoInterval)
101
102
  VISIT(List)
102
103
  VISIT(Struct)
103
104
  VISIT(Map)
@@ -47,6 +47,13 @@ namespace red_arrow {
47
47
  extern ID id_new;
48
48
  extern ID id_to_datetime;
49
49
 
50
+ namespace symbols {
51
+ extern VALUE day;
52
+ extern VALUE millisecond;
53
+ extern VALUE month;
54
+ extern VALUE nanosecond;
55
+ }
56
+
50
57
  VALUE array_values(VALUE obj);
51
58
  VALUE chunked_array_values(VALUE obj);
52
59
 
data/ext/arrow/values.cpp CHANGED
@@ -77,8 +77,9 @@ namespace red_arrow {
77
77
  VISIT(Time32)
78
78
  VISIT(Time64)
79
79
  VISIT(Timestamp)
80
- // TODO
81
- // VISIT(Interval)
80
+ VISIT(MonthInterval)
81
+ VISIT(DayTimeInterval)
82
+ VISIT(MonthDayNanoInterval)
82
83
  VISIT(List)
83
84
  VISIT(Struct)
84
85
  VISIT(Map)
@@ -0,0 +1,29 @@
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 Arrow
19
+ class DayTimeIntervalArrayBuilder
20
+ private
21
+ def convert_to_arrow_value(value)
22
+ if value.is_a?(Hash)
23
+ Arrow::DayMillisecond.new(value[:day], value[:millisecond])
24
+ else
25
+ value
26
+ end
27
+ end
28
+ end
29
+ end
data/lib/arrow/loader.rb CHANGED
@@ -59,6 +59,7 @@ module Arrow
59
59
  require "arrow/date64-array"
60
60
  require "arrow/date64-array-builder"
61
61
  require "arrow/datum"
62
+ require "arrow/day-time-interval-array-builder"
62
63
  require "arrow/decimal128"
63
64
  require "arrow/decimal128-array"
64
65
  require "arrow/decimal128-array-builder"
@@ -84,6 +85,7 @@ module Arrow
84
85
  require "arrow/map-array"
85
86
  require "arrow/map-array-builder"
86
87
  require "arrow/map-data-type"
88
+ require "arrow/month-day-nano-interval-array-builder"
87
89
  require "arrow/null-array"
88
90
  require "arrow/null-array-builder"
89
91
  require "arrow/path-extension"
@@ -0,0 +1,29 @@
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 Arrow
19
+ class MonthDayNanoIntervalArrayBuilder
20
+ private
21
+ def convert_to_arrow_value(value)
22
+ if value.is_a?(Hash)
23
+ Arrow::MonthDayNano.new(value[:month], value[:day], value[:nanosecond])
24
+ else
25
+ value
26
+ end
27
+ end
28
+ end
29
+ end
data/lib/arrow/version.rb CHANGED
@@ -16,7 +16,7 @@
16
16
  # under the License.
17
17
 
18
18
  module Arrow
19
- VERSION = "7.0.0"
19
+ VERSION = "8.0.0"
20
20
 
21
21
  module Version
22
22
  numbers, TAG = VERSION.split("-")
@@ -346,6 +346,36 @@ module RawRecordsBasicArraysTests
346
346
  records)
347
347
  assert_equal(records, target.raw_records)
348
348
  end
349
+
350
+ def test_month_interval
351
+ records = [
352
+ [1],
353
+ [nil],
354
+ [12],
355
+ ]
356
+ target = build({column: :month_interval}, records)
357
+ assert_equal(records, target.raw_records)
358
+ end
359
+
360
+ def test_day_time_interval
361
+ records = [
362
+ [{day: 1, millisecond: 100}],
363
+ [nil],
364
+ [{day: 2, millisecond: 300}],
365
+ ]
366
+ target = build({column: :day_time_interval}, records)
367
+ assert_equal(records, target.raw_records)
368
+ end
369
+
370
+ def test_month_day_nano_interval
371
+ records = [
372
+ [{month: 1, day: 1, nanosecond: 100}],
373
+ [nil],
374
+ [{month: 2, day: 3, nanosecond: 400}],
375
+ ]
376
+ target = build({column: :month_day_nano_interval}, records)
377
+ assert_equal(records, target.raw_records)
378
+ end
349
379
  end
350
380
 
351
381
  class RawRecordsRecordBatchBasicArraysTest < Test::Unit::TestCase
@@ -359,6 +359,33 @@ module RawRecordsDenseUnionArrayTests
359
359
  assert_equal(records, target.raw_records)
360
360
  end
361
361
 
362
+ def test_month_interval
363
+ records = [
364
+ [{"0" => 1}],
365
+ [{"1" => nil}],
366
+ ]
367
+ target = build(:month_interval, records)
368
+ assert_equal(records, target.raw_records)
369
+ end
370
+
371
+ def test_day_time_interval
372
+ records = [
373
+ [{"0" => {day: 1, millisecond: 100}}],
374
+ [{"1" => nil}],
375
+ ]
376
+ target = build(:day_time_interval, records)
377
+ assert_equal(records, target.raw_records)
378
+ end
379
+
380
+ def test_month_day_nano_interval
381
+ records = [
382
+ [{"0" => {month: 1, day: 1, nanosecond: 100}}],
383
+ [{"1" => nil}],
384
+ ]
385
+ target = build(:month_day_nano_interval, records)
386
+ assert_equal(records, target.raw_records)
387
+ end
388
+
362
389
  def test_list
363
390
  records = [
364
391
  [{"0" => [true, nil, false]}],
@@ -399,6 +399,45 @@ module RawRecordsListArrayTests
399
399
  assert_equal(records, target.raw_records)
400
400
  end
401
401
 
402
+ def test_month_interval
403
+ records = [
404
+ [[1, nil, 12]],
405
+ [nil],
406
+ ]
407
+ target = build(:month_interval, records)
408
+ assert_equal(records, target.raw_records)
409
+ end
410
+
411
+ def test_day_time_interval
412
+ records = [
413
+ [
414
+ [
415
+ {day: 1, millisecond: 100},
416
+ nil,
417
+ {day: 2, millisecond: 300},
418
+ ]
419
+ ],
420
+ [nil],
421
+ ]
422
+ target = build(:day_time_interval, records)
423
+ assert_equal(records, target.raw_records)
424
+ end
425
+
426
+ def test_month_day_nano_interval
427
+ records = [
428
+ [
429
+ [
430
+ {month: 1, day: 1, nanosecond: 100},
431
+ nil,
432
+ {month: 2, day: 3, nanosecond: 400},
433
+ ]
434
+ ],
435
+ [nil],
436
+ ]
437
+ target = build(:month_day_nano_interval, records)
438
+ assert_equal(records, target.raw_records)
439
+ end
440
+
402
441
  def test_list
403
442
  records = [
404
443
  [
@@ -310,6 +310,43 @@ module RawRecordsMapArrayTests
310
310
  assert_equal(records, target.raw_records)
311
311
  end
312
312
 
313
+ def test_month_interval
314
+ records = [
315
+ [{"key1" => 1, "key2" => nil}],
316
+ [nil],
317
+ ]
318
+ target = build(:month_interval, records)
319
+ assert_equal(records, target.raw_records)
320
+ end
321
+
322
+ def test_day_time_interval
323
+ records = [
324
+ [
325
+ {
326
+ "key1" => {day: 1, millisecond: 100},
327
+ "key2" => nil,
328
+ },
329
+ ],
330
+ [nil],
331
+ ]
332
+ target = build(:day_time_interval, records)
333
+ assert_equal(records, target.raw_records)
334
+ end
335
+
336
+ def test_month_day_nano_interval
337
+ records = [
338
+ [
339
+ {
340
+ "key1" => {month: 1, day: 1, nanosecond: 100},
341
+ "key2" => nil,
342
+ },
343
+ ],
344
+ [nil],
345
+ ]
346
+ target = build(:month_day_nano_interval, records)
347
+ assert_equal(records, target.raw_records)
348
+ end
349
+
313
350
  def test_list
314
351
  records = [
315
352
  [{"key1" => [true, nil, false], "key2" => nil}],
@@ -349,6 +349,33 @@ module RawRecordsSparseUnionArrayTests
349
349
  assert_equal(records, target.raw_records)
350
350
  end
351
351
 
352
+ def test_month_interval
353
+ records = [
354
+ [{"0" => 1}],
355
+ [{"1" => nil}],
356
+ ]
357
+ target = build(:month_interval, records)
358
+ assert_equal(records, target.raw_records)
359
+ end
360
+
361
+ def test_day_time_interval
362
+ records = [
363
+ [{"0" => {day: 1, millisecond: 100}}],
364
+ [{"1" => nil}],
365
+ ]
366
+ target = build(:day_time_interval, records)
367
+ assert_equal(records, target.raw_records)
368
+ end
369
+
370
+ def test_month_day_nano_interval
371
+ records = [
372
+ [{"0" => {month: 1, day: 1, nanosecond: 100}}],
373
+ [{"1" => nil}],
374
+ ]
375
+ target = build(:month_day_nano_interval, records)
376
+ assert_equal(records, target.raw_records)
377
+ end
378
+
352
379
  def test_list
353
380
  records = [
354
381
  [{"0" => [true, nil, false]}],
@@ -344,6 +344,36 @@ module RawRecordsStructArrayTests
344
344
  assert_equal(records, target.raw_records)
345
345
  end
346
346
 
347
+ def test_month_interval
348
+ records = [
349
+ [{"field" => 1}],
350
+ [nil],
351
+ [{"field" => nil}],
352
+ ]
353
+ target = build(:month_interval, records)
354
+ assert_equal(records, target.raw_records)
355
+ end
356
+
357
+ def test_day_time_interval
358
+ records = [
359
+ [{"field" => {day: 1, millisecond: 100}}],
360
+ [nil],
361
+ [{"field" => nil}],
362
+ ]
363
+ target = build(:day_time_interval, records)
364
+ assert_equal(records, target.raw_records)
365
+ end
366
+
367
+ def test_month_day_nano_interval
368
+ records = [
369
+ [{"field" => {month: 1, day: 1, nanosecond: 100}}],
370
+ [nil],
371
+ [{"field" => nil}],
372
+ ]
373
+ target = build(:month_day_nano_interval, records)
374
+ assert_equal(records, target.raw_records)
375
+ end
376
+
347
377
  def test_list
348
378
  records = [
349
379
  [{"field" => [true, nil, false]}],
data/test/test-table.rb CHANGED
@@ -186,7 +186,12 @@ class TableTest < Test::Unit::TestCase
186
186
  end
187
187
 
188
188
  test("{key: Range}: beginless include end") do
189
- assert_equal(<<-TABLE, @table.slice(count: ..8).to_s)
189
+ begin
190
+ range = eval("..8")
191
+ rescue SyntaxError
192
+ omit("beginless range isn't supported")
193
+ end
194
+ assert_equal(<<-TABLE, @table.slice(count: range).to_s)
190
195
  count visible
191
196
  0 1 true
192
197
  1 2 false
@@ -196,7 +201,12 @@ class TableTest < Test::Unit::TestCase
196
201
  end
197
202
 
198
203
  test("{key: Range}: beginless exclude end") do
199
- assert_equal(<<-TABLE, @table.slice(count: ...8).to_s)
204
+ begin
205
+ range = eval("...8")
206
+ rescue SyntaxError
207
+ omit("beginless range isn't supported")
208
+ end
209
+ assert_equal(<<-TABLE, @table.slice(count: range).to_s)
200
210
  count visible
201
211
  0 1 true
202
212
  1 2 false
@@ -205,7 +215,12 @@ class TableTest < Test::Unit::TestCase
205
215
  end
206
216
 
207
217
  test("{key: Range}: endless") do
208
- assert_equal(<<-TABLE, @table.slice(count: 16..).to_s)
218
+ begin
219
+ range = eval("16..")
220
+ rescue SyntaxError
221
+ omit("endless range isn't supported")
222
+ end
223
+ assert_equal(<<-TABLE, @table.slice(count: range).to_s)
209
224
  count visible
210
225
  0 16 true
211
226
  1 32 false
@@ -276,6 +276,36 @@ module ValuesBasicArraysTests
276
276
  target = build(Arrow::Decimal256Array.new(data_type, values))
277
277
  assert_equal(values, target.values)
278
278
  end
279
+
280
+ def test_month_interval
281
+ values = [
282
+ 1,
283
+ nil,
284
+ 12,
285
+ ]
286
+ target = build(Arrow::MonthIntervalArray.new(values))
287
+ assert_equal(values, target.values)
288
+ end
289
+
290
+ def test_day_time_interval
291
+ values = [
292
+ {day: 1, millisecond: 100},
293
+ nil,
294
+ {day: 2, millisecond: 300},
295
+ ]
296
+ target = build(Arrow::DayTimeIntervalArray.new(values))
297
+ assert_equal(values, target.values)
298
+ end
299
+
300
+ def test_month_day_nano_interval
301
+ values = [
302
+ {month: 1, day: 1, nanosecond: 100},
303
+ nil,
304
+ {month: 2, day: 3, nanosecond: 400},
305
+ ]
306
+ target = build(Arrow::MonthDayNanoIntervalArray.new(values))
307
+ assert_equal(values, target.values)
308
+ end
279
309
  end
280
310
 
281
311
  class ValuesArrayBasicArraysTest < Test::Unit::TestCase
@@ -347,6 +347,33 @@ module ValuesDenseUnionArrayTests
347
347
  assert_equal(values, target.values)
348
348
  end
349
349
 
350
+ def test_month_interval
351
+ values = [
352
+ {"0" => 1},
353
+ {"1" => nil},
354
+ ]
355
+ target = build(:month_interval, values)
356
+ assert_equal(values, target.values)
357
+ end
358
+
359
+ def test_day_time_interval
360
+ values = [
361
+ {"0" => {day: 1, millisecond: 100}},
362
+ {"1" => nil},
363
+ ]
364
+ target = build(:day_time_interval, values)
365
+ assert_equal(values, target.values)
366
+ end
367
+
368
+ def test_month_day_nano_interval
369
+ values = [
370
+ {"0" => {month: 1, day: 1, nanosecond: 100}},
371
+ {"1" => nil},
372
+ ]
373
+ target = build(:month_day_nano_interval, values)
374
+ assert_equal(values, target.values)
375
+ end
376
+
350
377
  def test_list
351
378
  values = [
352
379
  {"0" => [true, nil, false]},
@@ -0,0 +1,295 @@
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 ValuesDictionaryArrayTests
19
+ def test_null
20
+ target = build(Arrow::NullArray.new(4))
21
+ assert_equal([nil] * 4, target.values)
22
+ end
23
+
24
+ def test_boolean
25
+ values = [true, nil, false]
26
+ target = build(Arrow::BooleanArray.new(values))
27
+ assert_equal(values, target.values)
28
+ end
29
+
30
+ def test_int8
31
+ values = [
32
+ -(2 ** 7),
33
+ nil,
34
+ (2 ** 7) - 1,
35
+ ]
36
+ target = build(Arrow::Int8Array.new(values))
37
+ assert_equal(values, target.values)
38
+ end
39
+
40
+ def test_uint8
41
+ values = [
42
+ 0,
43
+ nil,
44
+ (2 ** 8) - 1,
45
+ ]
46
+ target = build(Arrow::UInt8Array.new(values))
47
+ assert_equal(values, target.values)
48
+ end
49
+
50
+ def test_int16
51
+ values = [
52
+ -(2 ** 15),
53
+ nil,
54
+ (2 ** 15) - 1,
55
+ ]
56
+ target = build(Arrow::Int16Array.new(values))
57
+ assert_equal(values, target.values)
58
+ end
59
+
60
+ def test_uint16
61
+ values = [
62
+ 0,
63
+ nil,
64
+ (2 ** 16) - 1,
65
+ ]
66
+ target = build(Arrow::UInt16Array.new(values))
67
+ assert_equal(values, target.values)
68
+ end
69
+
70
+ def test_int32
71
+ values = [
72
+ -(2 ** 31),
73
+ nil,
74
+ (2 ** 31) - 1,
75
+ ]
76
+ target = build(Arrow::Int32Array.new(values))
77
+ assert_equal(values, target.values)
78
+ end
79
+
80
+ def test_uint32
81
+ values = [
82
+ 0,
83
+ nil,
84
+ (2 ** 32) - 1,
85
+ ]
86
+ target = build(Arrow::UInt32Array.new(values))
87
+ assert_equal(values, target.values)
88
+ end
89
+
90
+ def test_int64
91
+ values = [
92
+ -(2 ** 63),
93
+ nil,
94
+ (2 ** 63) - 1,
95
+ ]
96
+ target = build(Arrow::Int64Array.new(values))
97
+ assert_equal(values, target.values)
98
+ end
99
+
100
+ def test_uint64
101
+ values = [
102
+ 0,
103
+ nil,
104
+ (2 ** 64) - 1,
105
+ ]
106
+ target = build(Arrow::UInt64Array.new(values))
107
+ assert_equal(values, target.values)
108
+ end
109
+
110
+ def test_float
111
+ values = [
112
+ -1.0,
113
+ nil,
114
+ 1.0,
115
+ ]
116
+ target = build(Arrow::FloatArray.new(values))
117
+ assert_equal(values, target.values)
118
+ end
119
+
120
+ def test_double
121
+ values = [
122
+ -1.0,
123
+ nil,
124
+ 1.0,
125
+ ]
126
+ target = build(Arrow::DoubleArray.new(values))
127
+ assert_equal(values, target.values)
128
+ end
129
+
130
+ def test_binary
131
+ values = [
132
+ "\x00".b,
133
+ nil,
134
+ "\xff".b,
135
+ ]
136
+ target = build(Arrow::BinaryArray.new(values))
137
+ assert_equal(values, target.values)
138
+ end
139
+
140
+ def test_string
141
+ values = [
142
+ "Ruby",
143
+ nil,
144
+ "\u3042", # U+3042 HIRAGANA LETTER A
145
+ ]
146
+ target = build(Arrow::StringArray.new(values))
147
+ assert_equal(values, target.values)
148
+ end
149
+
150
+ def test_date32
151
+ values = [
152
+ Date.new(1960, 1, 1),
153
+ nil,
154
+ Date.new(2017, 8, 23),
155
+ ]
156
+ target = build(Arrow::Date32Array.new(values))
157
+ assert_equal(values, target.values)
158
+ end
159
+
160
+ def test_date64
161
+ values = [
162
+ DateTime.new(1960, 1, 1, 2, 9, 30),
163
+ nil,
164
+ DateTime.new(2017, 8, 23, 14, 57, 2),
165
+ ]
166
+ target = build(Arrow::Date64Array.new(values))
167
+ assert_equal(values, target.values)
168
+ end
169
+
170
+ def test_timestamp_second
171
+ values = [
172
+ Time.parse("1960-01-01T02:09:30Z"),
173
+ nil,
174
+ Time.parse("2017-08-23T14:57:02Z"),
175
+ ]
176
+ target = build(Arrow::TimestampArray.new(:second, values))
177
+ assert_equal(values, target.values)
178
+ end
179
+
180
+ def test_timestamp_milli
181
+ values = [
182
+ Time.parse("1960-01-01T02:09:30.123Z"),
183
+ nil,
184
+ Time.parse("2017-08-23T14:57:02.987Z"),
185
+ ]
186
+ target = build(Arrow::TimestampArray.new(:milli, values))
187
+ assert_equal(values, target.values)
188
+ end
189
+
190
+ def test_timestamp_micro
191
+ values = [
192
+ Time.parse("1960-01-01T02:09:30.123456Z"),
193
+ nil,
194
+ Time.parse("2017-08-23T14:57:02.987654Z"),
195
+ ]
196
+ target = build(Arrow::TimestampArray.new(:micro, values))
197
+ assert_equal(values, target.values)
198
+ end
199
+
200
+ def test_timestamp_nano
201
+ values = [
202
+ Time.parse("1960-01-01T02:09:30.123456789Z"),
203
+ nil,
204
+ Time.parse("2017-08-23T14:57:02.987654321Z"),
205
+ ]
206
+ target = build(Arrow::TimestampArray.new(:nano, values))
207
+ assert_equal(values, target.values)
208
+ end
209
+
210
+ def test_time32_second
211
+ unit = Arrow::TimeUnit::SECOND
212
+ values = [
213
+ Arrow::Time.new(unit, 60 * 10), # 00:10:00
214
+ nil,
215
+ Arrow::Time.new(unit, 60 * 60 * 2 + 9), # 02:00:09
216
+ ]
217
+ target = build(Arrow::Time32Array.new(unit, values))
218
+ assert_equal(values, target.values)
219
+ end
220
+
221
+ def test_time32_milli
222
+ unit = Arrow::TimeUnit::MILLI
223
+ values = [
224
+ Arrow::Time.new(unit, (60 * 10) * 1000 + 123), # 00:10:00.123
225
+ nil,
226
+ Arrow::Time.new(unit, (60 * 60 * 2 + 9) * 1000 + 987), # 02:00:09.987
227
+ ]
228
+ target = build(Arrow::Time32Array.new(unit, values))
229
+ assert_equal(values, target.values)
230
+ end
231
+
232
+ def test_time64_micro
233
+ unit = Arrow::TimeUnit::MICRO
234
+ values = [
235
+ # 00:10:00.123456
236
+ Arrow::Time.new(unit, (60 * 10) * 1_000_000 + 123_456),
237
+ nil,
238
+ # 02:00:09.987654
239
+ Arrow::Time.new(unit, (60 * 60 * 2 + 9) * 1_000_000 + 987_654),
240
+ ]
241
+ target = build(Arrow::Time64Array.new(unit, values))
242
+ assert_equal(values, target.values)
243
+ end
244
+
245
+ def test_time64_nano
246
+ unit = Arrow::TimeUnit::NANO
247
+ values = [
248
+ # 00:10:00.123456789
249
+ Arrow::Time.new(unit, (60 * 10) * 1_000_000_000 + 123_456_789),
250
+ nil,
251
+ # 02:00:09.987654321
252
+ Arrow::Time.new(unit, (60 * 60 * 2 + 9) * 1_000_000_000 + 987_654_321),
253
+ ]
254
+ target = build(Arrow::Time64Array.new(unit, values))
255
+ assert_equal(values, target.values)
256
+ end
257
+
258
+ def test_decimal128
259
+ values = [
260
+ BigDecimal("92.92"),
261
+ nil,
262
+ BigDecimal("29.29"),
263
+ ]
264
+ data_type = Arrow::Decimal128DataType.new(8, 2)
265
+ target = build(Arrow::Decimal128Array.new(data_type, values))
266
+ assert_equal(values, target.values)
267
+ end
268
+
269
+ def test_decimal256
270
+ values = [
271
+ BigDecimal("92.92"),
272
+ nil,
273
+ BigDecimal("29.29"),
274
+ ]
275
+ data_type = Arrow::Decimal256DataType.new(38, 2)
276
+ target = build(Arrow::Decimal256Array.new(data_type, values))
277
+ assert_equal(values, target.values)
278
+ end
279
+ end
280
+
281
+ class ValuesArrayDictionaryArrayTest < Test::Unit::TestCase
282
+ include ValuesDictionaryArrayTests
283
+
284
+ def build(values)
285
+ values.dictionary_encode
286
+ end
287
+ end
288
+
289
+ class ValuesChunkedArrayDictionaryArrayTest < Test::Unit::TestCase
290
+ include ValuesDictionaryArrayTests
291
+
292
+ def build(values)
293
+ Arrow::ChunkedArray.new([values.dictionary_encode])
294
+ end
295
+ end
@@ -372,6 +372,45 @@ module ValuesListArrayTests
372
372
  assert_equal(values, target.values)
373
373
  end
374
374
 
375
+ def test_month_interval
376
+ values = [
377
+ [
378
+ 1,
379
+ nil,
380
+ 12,
381
+ ],
382
+ nil,
383
+ ]
384
+ target = build(:month_interval, values)
385
+ assert_equal(values, target.values)
386
+ end
387
+
388
+ def test_day_time_interval
389
+ values = [
390
+ [
391
+ {day: 1, millisecond: 100},
392
+ nil,
393
+ {day: 2, millisecond: 300},
394
+ ],
395
+ nil,
396
+ ]
397
+ target = build(:day_time_interval, values)
398
+ assert_equal(values, target.values)
399
+ end
400
+
401
+ def test_month_day_nano_interval
402
+ values = [
403
+ [
404
+ {month: 1, day: 1, nanosecond: 100},
405
+ nil,
406
+ {month: 2, day: 3, nanosecond: 400},
407
+ ],
408
+ nil,
409
+ ]
410
+ target = build(:month_day_nano_interval, values)
411
+ assert_equal(values, target.values)
412
+ end
413
+
375
414
  def test_list
376
415
  values = [
377
416
  [
@@ -302,6 +302,39 @@ module ValuesMapArrayTests
302
302
  assert_equal(values, target.values)
303
303
  end
304
304
 
305
+ def test_month_interval
306
+ values = [
307
+ {"key1" => 1, "key2" => nil},
308
+ nil,
309
+ ]
310
+ target = build(:month_interval, values)
311
+ assert_equal(values, target.values)
312
+ end
313
+
314
+ def test_day_time_interval
315
+ values = [
316
+ {
317
+ "key1" => {day: 1, millisecond: 100},
318
+ "key2" => nil,
319
+ },
320
+ nil,
321
+ ]
322
+ target = build(:day_time_interval, values)
323
+ assert_equal(values, target.values)
324
+ end
325
+
326
+ def test_month_day_nano_interval
327
+ values = [
328
+ {
329
+ "key1" => {month: 1, day: 1, nanosecond: 100},
330
+ "key2" => nil,
331
+ },
332
+ nil,
333
+ ]
334
+ target = build(:month_day_nano_interval, values)
335
+ assert_equal(values, target.values)
336
+ end
337
+
305
338
  def test_list
306
339
  values = [
307
340
  {"key1" => [true, nil, false], "key2" => nil},
@@ -324,6 +324,33 @@ module ValuesSparseUnionArrayTests
324
324
  assert_equal(values, target.values)
325
325
  end
326
326
 
327
+ def test_month_interval
328
+ values = [
329
+ {"0" => 1},
330
+ {"1" => nil},
331
+ ]
332
+ target = build(:month_interval, values)
333
+ assert_equal(values, target.values)
334
+ end
335
+
336
+ def test_day_time_interval
337
+ values = [
338
+ {"0" => {day: 1, millisecond: 100}},
339
+ {"1" => nil},
340
+ ]
341
+ target = build(:day_time_interval, values)
342
+ assert_equal(values, target.values)
343
+ end
344
+
345
+ def test_month_day_nano_interval
346
+ values = [
347
+ {"0" => {month: 1, day: 1, nanosecond: 100}},
348
+ {"1" => nil},
349
+ ]
350
+ target = build(:month_day_nano_interval, values)
351
+ assert_equal(values, target.values)
352
+ end
353
+
327
354
  def test_decimal256
328
355
  values = [
329
356
  {"0" => BigDecimal("92.92")},
@@ -341,6 +341,36 @@ module ValuesStructArrayTests
341
341
  assert_equal(values, target.values)
342
342
  end
343
343
 
344
+ def test_month_interval
345
+ values = [
346
+ {"field" => 1},
347
+ nil,
348
+ {"field" => nil},
349
+ ]
350
+ target = build(:month_interval, values)
351
+ assert_equal(values, target.values)
352
+ end
353
+
354
+ def test_day_time_interval
355
+ values = [
356
+ {"field" => {day: 1, millisecond: 100}},
357
+ nil,
358
+ {"field" => nil},
359
+ ]
360
+ target = build(:day_time_interval, values)
361
+ assert_equal(values, target.values)
362
+ end
363
+
364
+ def test_month_day_nano_interval
365
+ values = [
366
+ {"field" => {month: 1, day: 1, nanosecond: 100}},
367
+ nil,
368
+ {"field" => nil},
369
+ ]
370
+ target = build(:month_day_nano_interval, values)
371
+ assert_equal(values, target.values)
372
+ end
373
+
344
374
  def test_list
345
375
  values = [
346
376
  {"field" => [true, nil, false]},
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: red-arrow
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.0
4
+ version: 8.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Apache Arrow Developers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-05 00:00:00.000000000 Z
11
+ date: 2022-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bigdecimal
@@ -127,6 +127,7 @@ files:
127
127
  - lib/arrow/date64-array-builder.rb
128
128
  - lib/arrow/date64-array.rb
129
129
  - lib/arrow/datum.rb
130
+ - lib/arrow/day-time-interval-array-builder.rb
130
131
  - lib/arrow/decimal128-array-builder.rb
131
132
  - lib/arrow/decimal128-array.rb
132
133
  - lib/arrow/decimal128-data-type.rb
@@ -156,6 +157,7 @@ files:
156
157
  - lib/arrow/map-array-builder.rb
157
158
  - lib/arrow/map-array.rb
158
159
  - lib/arrow/map-data-type.rb
160
+ - lib/arrow/month-day-nano-interval-array-builder.rb
159
161
  - lib/arrow/null-array-builder.rb
160
162
  - lib/arrow/null-array.rb
161
163
  - lib/arrow/path-extension.rb
@@ -292,6 +294,7 @@ files:
292
294
  - test/test-timestamp-data-type.rb
293
295
  - test/values/test-basic-arrays.rb
294
296
  - test/values/test-dense-union-array.rb
297
+ - test/values/test-dictionary-array.rb
295
298
  - test/values/test-list-array.rb
296
299
  - test/values/test-map-array.rb
297
300
  - test/values/test-sparse-union-array.rb
@@ -300,7 +303,7 @@ homepage: https://arrow.apache.org/
300
303
  licenses:
301
304
  - Apache-2.0
302
305
  metadata:
303
- msys2_mingw_dependencies: arrow>=7.0.0
306
+ msys2_mingw_dependencies: arrow>=8.0.0
304
307
  post_install_message:
305
308
  rdoc_options: []
306
309
  require_paths:
@@ -410,6 +413,7 @@ test_files:
410
413
  - test/test-timestamp-data-type.rb
411
414
  - test/values/test-basic-arrays.rb
412
415
  - test/values/test-dense-union-array.rb
416
+ - test/values/test-dictionary-array.rb
413
417
  - test/values/test-list-array.rb
414
418
  - test/values/test-map-array.rb
415
419
  - test/values/test-sparse-union-array.rb