You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/03/11 09:18:38 UTC
[GitHub] [arrow] kou commented on a change in pull request #12593: ARROW-15885 [Ruby] Add support for #values of DayTime Interval Type
kou commented on a change in pull request #12593:
URL: https://github.com/apache/arrow/pull/12593#discussion_r824524199
##########
File path: ruby/red-arrow/ext/arrow/converters.hpp
##########
@@ -207,6 +207,21 @@ namespace red_arrow {
return INT2NUM(array.Value(i));
}
+ inline VALUE convert(const arrow::DayTimeIntervalArray& array,
+ const int64_t i) {
+
Review comment:
```suggestion
```
##########
File path: ruby/red-arrow/test/values/test-basic-arrays.rb
##########
@@ -286,6 +286,21 @@ def test_month_interval
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},
+ ]
+ inputs = [
+ Arrow::DayMillisecond.new(1, 100),
+ nil,
+ Arrow::DayMillisecond.new(2, 300),
+ ]
+ target = build(Arrow::DayTimeIntervalArray.new(inputs))
Review comment:
Ah, we should add support for `Arrow::DayTimeIntervalArray.new([{day: 1, millisecond: 100}, nil, {...}])`.
Could you open an issue for this improvement?
##########
File path: ruby/red-arrow/ext/arrow/converters.hpp
##########
@@ -207,6 +207,21 @@ namespace red_arrow {
return INT2NUM(array.Value(i));
}
+ inline VALUE convert(const arrow::DayTimeIntervalArray& array,
+ const int64_t i) {
+
+ auto value = rb_hash_new();
+ auto arrow_value = array.Value(i);
+ rb_hash_aset(value,
+ red_arrow::symbols::day,
+ INT2NUM(arrow_value.days));
+ rb_hash_aset(value,
+ red_arrow::symbols::millisecond,
+ INT2NUM(arrow_value.milliseconds));
+
Review comment:
```suggestion
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org