You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ko...@apache.org on 2022/05/30 07:36:03 UTC
[arrow] branch master updated: ARROW-16206: [Ruby] Add support for DictionaryArray#values, #raw_records with {Month,DayTime,MonthDayNano} Interval Type (#13255)
This is an automated email from the ASF dual-hosted git repository.
kou pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/master by this push:
new 84a8d6bf6d ARROW-16206: [Ruby] Add support for DictionaryArray#values, #raw_records with {Month,DayTime,MonthDayNano} Interval Type (#13255)
84a8d6bf6d is described below
commit 84a8d6bf6dea7b1762c68cc00d5696f78346f72a
Author: okadak <k....@gmail.com>
AuthorDate: Mon May 30 16:35:56 2022 +0900
ARROW-16206: [Ruby] Add support for DictionaryArray#values, #raw_records with {Month,DayTime,MonthDayNano} Interval Type (#13255)
I added support for DictionaryArray#values, #raw_records with Interval Types.
Authored-by: okadakk <k....@gmail.com>
Signed-off-by: Sutou Kouhei <ko...@clear-code.com>
---
ruby/red-arrow/ext/arrow/converters.hpp | 3 +++
.../test/raw-records/test-dictionary-array.rb | 30 ++++++++++++++++++++++
.../red-arrow/test/values/test-dictionary-array.rb | 30 ++++++++++++++++++++++
3 files changed, 63 insertions(+)
diff --git a/ruby/red-arrow/ext/arrow/converters.hpp b/ruby/red-arrow/ext/arrow/converters.hpp
index 07a6fefe24..5a500574de 100644
--- a/ruby/red-arrow/ext/arrow/converters.hpp
+++ b/ruby/red-arrow/ext/arrow/converters.hpp
@@ -773,6 +773,9 @@ namespace red_arrow {
VISIT(Time32)
VISIT(Time64)
VISIT(Timestamp)
+ VISIT(MonthInterval)
+ VISIT(DayTimeInterval)
+ VISIT(MonthDayNanoInterval)
VISIT(List)
VISIT(Struct)
VISIT(Map)
diff --git a/ruby/red-arrow/test/raw-records/test-dictionary-array.rb b/ruby/red-arrow/test/raw-records/test-dictionary-array.rb
index cac547caf7..200185bde4 100644
--- a/ruby/red-arrow/test/raw-records/test-dictionary-array.rb
+++ b/ruby/red-arrow/test/raw-records/test-dictionary-array.rb
@@ -292,6 +292,36 @@ module RawRecordsDictionaryArrayTests
target = build(Arrow::Decimal256Array.new(data_type, records.collect(&:first)))
assert_equal(records, target.raw_records)
end
+
+ def test_month_interval
+ records = [
+ [1],
+ [nil],
+ [12],
+ ]
+ target = build(Arrow::MonthIntervalArray.new(records.collect(&:first)))
+ assert_equal(records, target.raw_records)
+ end
+
+ def test_day_time_interval
+ records = [
+ [{day: 1, millisecond: 100}],
+ [nil],
+ [{day: 2, millisecond: 300}],
+ ]
+ target = build(Arrow::DayTimeIntervalArray.new(records.collect(&:first)))
+ assert_equal(records, target.raw_records)
+ end
+
+ def test_month_day_nano_interval
+ records = [
+ [{month: 1, day: 1, nanosecond: 100}],
+ [nil],
+ [{month: 2, day: 3, nanosecond: 400}],
+ ]
+ target = build(Arrow::MonthDayNanoIntervalArray.new(records.collect(&:first)))
+ assert_equal(records, target.raw_records)
+ end
end
class RawRecordsRecordBatchDictionaryArraysTest < Test::Unit::TestCase
diff --git a/ruby/red-arrow/test/values/test-dictionary-array.rb b/ruby/red-arrow/test/values/test-dictionary-array.rb
index 4cbccdc32f..115656b7d7 100644
--- a/ruby/red-arrow/test/values/test-dictionary-array.rb
+++ b/ruby/red-arrow/test/values/test-dictionary-array.rb
@@ -276,6 +276,36 @@ module ValuesDictionaryArrayTests
target = build(Arrow::Decimal256Array.new(data_type, values))
assert_equal(values, target.values)
end
+
+ def test_month_interval
+ values = [
+ 1,
+ nil,
+ 12,
+ ]
+ target = build(Arrow::MonthIntervalArray.new(values))
+ assert_equal(values, target.values)
+ end
+
+ def test_day_time_interval
+ values = [
+ {day: 1, millisecond: 100},
+ nil,
+ {day: 2, millisecond: 300},
+ ]
+ target = build(Arrow::DayTimeIntervalArray.new(values))
+ assert_equal(values, target.values)
+ end
+
+ def test_month_day_nano_interval
+ values = [
+ {month: 1, day: 1, nanosecond: 100},
+ nil,
+ {month: 2, day: 3, nanosecond: 400},
+ ]
+ target = build(Arrow::MonthDayNanoIntervalArray.new(values))
+ assert_equal(values, target.values)
+ end
end
class ValuesArrayDictionaryArrayTest < Test::Unit::TestCase