You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "kou (via GitHub)" <gi...@apache.org> on 2026/01/29 07:35:20 UTC
[PR] GH-49053: [Ruby] Add support for writing timestamp array [arrow]
kou opened a new pull request, #49054:
URL: https://github.com/apache/arrow/pull/49054
### Rationale for this change
It has `unit` and `time_zone` parameters.
### What changes are included in this PR?
* Add `ArrowFormat::TimestampType#to_flatbuffers`
* Set time zone when GLib timestamp type is converted from C++ timestamp type
* Use `time_zone` not `timezone`
### Are these changes tested?
Yes.
### Are there any user-facing changes?
Yes.
--
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
Re: [PR] GH-49053: [Ruby] Add support for writing timestamp array [arrow]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #49054:
URL: https://github.com/apache/arrow/pull/49054#issuecomment-3815977901
:warning: GitHub issue #49053 **has been automatically assigned in GitHub** to PR creator.
--
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
Re: [PR] GH-49053: [Ruby] Add support for writing timestamp array [arrow]
Posted by "kou (via GitHub)" <gi...@apache.org>.
kou merged PR #49054:
URL: https://github.com/apache/arrow/pull/49054
--
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
Re: [PR] GH-49053: [Ruby] Add support for writing timestamp array [arrow]
Posted by "hiroyuki-sato (via GitHub)" <gi...@apache.org>.
hiroyuki-sato commented on code in PR #49054:
URL: https://github.com/apache/arrow/pull/49054#discussion_r2741399245
##########
ruby/red-arrow-format/test/test-writer.rb:
##########
@@ -388,6 +389,134 @@ def test_write
end
end
+ sub_test_case("Timestamp(:second)") do
+ def setup(&block)
+ @timestamp_2019_11_17_15_09_11 = 1574003351
+ @timestamp_2025_12_16_05_33_58 = 1765863238
+ super(&block)
+ end
+
+ def build_array
+ Arrow::TimestampArray.new(:second,
+ [
+ @timestamp_2019_11_17_15_09_11,
+ nil,
+ @timestamp_2025_12_16_05_33_58,
+ ])
+ end
+
+ def test_write
+ assert_equal([
+ Time.at(@timestamp_2019_11_17_15_09_11),
+ nil,
+ Time.at(@timestamp_2025_12_16_05_33_58),
+ ],
+ @values)
+ end
+ end
+
+ sub_test_case("Timestamp(:millisecond)") do
+ def setup(&block)
+ @timestamp_2019_11_17_15_09_11 = 1574003351 * 1_000
+ @timestamp_2025_12_16_05_33_58 = 1765863238 * 1_000
+ super(&block)
+ end
+
+ def build_array
+ Arrow::TimestampArray.new(:milli,
+ [
+ @timestamp_2019_11_17_15_09_11,
+ nil,
+ @timestamp_2025_12_16_05_33_58,
+ ])
+ end
+
+ def test_write
+ assert_equal([
+ Time.at(@timestamp_2019_11_17_15_09_11 / 1_000),
+ nil,
+ Time.at(@timestamp_2025_12_16_05_33_58 / 1_000),
+ ],
+ @values)
+ end
+ end
+
+ sub_test_case("Timestamp(:microsecond)") do
+ def setup(&block)
+ @timestamp_2019_11_17_15_09_11 = 1574003351 * 1_000_000
+ @timestamp_2025_12_16_05_33_58 = 1765863238 * 1_000_000
+ super(&block)
+ end
+
+ def build_array
+ Arrow::TimestampArray.new(:micro,
+ [
+ @timestamp_2019_11_17_15_09_11,
+ nil,
+ @timestamp_2025_12_16_05_33_58,
+ ])
+ end
+
+ def test_write
+ assert_equal([
+ Time.at(@timestamp_2019_11_17_15_09_11 / 1_000_000),
+ nil,
+ Time.at(@timestamp_2025_12_16_05_33_58 / 1_000_000),
+ ],
+ @values)
+ end
+ end
+
+ sub_test_case("Timestamp(:nanosecond)") do
+ def setup(&block)
+ @timestamp_2019_11_17_15_09_11 = 1574003351 * 1_000_000_000
+ @timestamp_2025_12_16_05_33_58 = 1765863238 * 1_000_000_000
+ super(&block)
+ end
+
+ def build_array
+ Arrow::TimestampArray.new(:nano,
+ [
+ @timestamp_2019_11_17_15_09_11,
+ nil,
+ @timestamp_2025_12_16_05_33_58,
+ ])
+ end
+
+ def test_write
+ assert_equal([
+ Time.at(@timestamp_2019_11_17_15_09_11 / 1_000_000_000),
+ nil,
+ Time.at(@timestamp_2025_12_16_05_33_58 / 1_000_000_000),
+ ],
+ @values)
+ end
+ end
+
+ sub_test_case("Timestamp(time_zone)") do
+ def setup(&block)
+ @time_zone = "UTC"
+ @timestamp_2019_11_17_15_09_11 = 1574003351
+ @timestamp_2025_12_16_05_33_58 = 1765863238
+ super(&block)
+ end
+
+ def build_array
+ data_type = Arrow::TimestampDataType.new(:second, @time_zone)
+ Arrow::TimestampArray.new(data_type,
+ [
+ @timestamp_2019_11_17_15_09_11,
+ nil,
+ @timestamp_2025_12_16_05_33_58,
+ ])
+ end
+
+ def test_type
+ assert_equal([Arrow::TimeUnit::SECOND, @time_zone],
+ [@type.unit, @type.time_zone&.identifier])
Review Comment:
**(EDIT: This was my environment issue.)**
~~`@type` correct? Is this my environment issue?~~
```
LD_LIBRARY_PATH=/tmp/local/lib:/path/to/arrow/red-arrow/ext/arrow/ GI_TYPELIB_PATH=/tmp/local/lib/girepository-1.0 rake -I /path/to/arrow/ruby/red-arrow/lib test
cd /path/to/arrow/ruby/red-arrow-format
/path/to/.rbenv/versions/3.4.7/bin/ruby test/run.rb
Loaded suite test
Started
/path/to/arrow/ruby/red-arrow-format/lib/arrow-format/file-reader.rb:40: warning: IO::Buffer is experimental and both the Ruby and C interface may change in the future!
F
==============================================================================================================================================================================
Failure: test_type(TestFileWriter::Timestamp(time_zone))
/path/to/arrow/ruby/red-arrow-format/test/test-writer.rb:515:in 'test_type'
512: end
513:
514: def test_type
=> 515: assert_equal([Arrow::TimeUnit::SECOND, @time_zone],
516: [@type.unit, @type.time_zone&.identifier])
517: end
518: end
<[#<Arrow::TimeUnit second>, "UTC"]> expected but was
<[#<Arrow::TimeUnit second>, nil]>
diff:
? [#<Arrow::TimeUnit second>, "UTC"]
? nil
? ?????
==============================================================================================================================================================================
F
==============================================================================================================================================================================
Failure: test_type(TestStreamingWriter::Timestamp(time_zone))
/path/to/arrow/ruby/red-arrow-format/test/test-writer.rb:515:in 'test_type'
512: end
513:
514: def test_type
=> 515: assert_equal([Arrow::TimeUnit::SECOND, @time_zone],
516: [@type.unit, @type.time_zone&.identifier])
517: end
518: end
<[#<Arrow::TimeUnit second>, "UTC"]> expected but was
<[#<Arrow::TimeUnit second>, nil]>
diff:
? [#<Arrow::TimeUnit second>, "UTC"]
? nil
? ?????
==============================================================================================================================================================================
Finished in 1.756426992 seconds.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
160 tests, 160 assertions, 2 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
98.75% passed
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
91.09 tests/s, 91.09 assertions/s
rake aborted!
Command failed with status (1): [/path/to/.rbenv/versions/3.4.7/bin/ruby test/run.rb]
/path/to/arrow/ruby/red-arrow-format/Rakefile:38:in 'block (2 levels) in <top (required)>'
/path/to/arrow/ruby/red-arrow-format/Rakefile:37:in 'block in <top (required)>'
Tasks: TOP => test
(See full trace by running task with --trace)
```
--
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
Re: [PR] GH-49053: [Ruby] Add support for writing timestamp array [arrow]
Posted by "hiroyuki-sato (via GitHub)" <gi...@apache.org>.
hiroyuki-sato commented on code in PR #49054:
URL: https://github.com/apache/arrow/pull/49054#discussion_r2741399245
##########
ruby/red-arrow-format/test/test-writer.rb:
##########
@@ -388,6 +389,134 @@ def test_write
end
end
+ sub_test_case("Timestamp(:second)") do
+ def setup(&block)
+ @timestamp_2019_11_17_15_09_11 = 1574003351
+ @timestamp_2025_12_16_05_33_58 = 1765863238
+ super(&block)
+ end
+
+ def build_array
+ Arrow::TimestampArray.new(:second,
+ [
+ @timestamp_2019_11_17_15_09_11,
+ nil,
+ @timestamp_2025_12_16_05_33_58,
+ ])
+ end
+
+ def test_write
+ assert_equal([
+ Time.at(@timestamp_2019_11_17_15_09_11),
+ nil,
+ Time.at(@timestamp_2025_12_16_05_33_58),
+ ],
+ @values)
+ end
+ end
+
+ sub_test_case("Timestamp(:millisecond)") do
+ def setup(&block)
+ @timestamp_2019_11_17_15_09_11 = 1574003351 * 1_000
+ @timestamp_2025_12_16_05_33_58 = 1765863238 * 1_000
+ super(&block)
+ end
+
+ def build_array
+ Arrow::TimestampArray.new(:milli,
+ [
+ @timestamp_2019_11_17_15_09_11,
+ nil,
+ @timestamp_2025_12_16_05_33_58,
+ ])
+ end
+
+ def test_write
+ assert_equal([
+ Time.at(@timestamp_2019_11_17_15_09_11 / 1_000),
+ nil,
+ Time.at(@timestamp_2025_12_16_05_33_58 / 1_000),
+ ],
+ @values)
+ end
+ end
+
+ sub_test_case("Timestamp(:microsecond)") do
+ def setup(&block)
+ @timestamp_2019_11_17_15_09_11 = 1574003351 * 1_000_000
+ @timestamp_2025_12_16_05_33_58 = 1765863238 * 1_000_000
+ super(&block)
+ end
+
+ def build_array
+ Arrow::TimestampArray.new(:micro,
+ [
+ @timestamp_2019_11_17_15_09_11,
+ nil,
+ @timestamp_2025_12_16_05_33_58,
+ ])
+ end
+
+ def test_write
+ assert_equal([
+ Time.at(@timestamp_2019_11_17_15_09_11 / 1_000_000),
+ nil,
+ Time.at(@timestamp_2025_12_16_05_33_58 / 1_000_000),
+ ],
+ @values)
+ end
+ end
+
+ sub_test_case("Timestamp(:nanosecond)") do
+ def setup(&block)
+ @timestamp_2019_11_17_15_09_11 = 1574003351 * 1_000_000_000
+ @timestamp_2025_12_16_05_33_58 = 1765863238 * 1_000_000_000
+ super(&block)
+ end
+
+ def build_array
+ Arrow::TimestampArray.new(:nano,
+ [
+ @timestamp_2019_11_17_15_09_11,
+ nil,
+ @timestamp_2025_12_16_05_33_58,
+ ])
+ end
+
+ def test_write
+ assert_equal([
+ Time.at(@timestamp_2019_11_17_15_09_11 / 1_000_000_000),
+ nil,
+ Time.at(@timestamp_2025_12_16_05_33_58 / 1_000_000_000),
+ ],
+ @values)
+ end
+ end
+
+ sub_test_case("Timestamp(time_zone)") do
+ def setup(&block)
+ @time_zone = "UTC"
+ @timestamp_2019_11_17_15_09_11 = 1574003351
+ @timestamp_2025_12_16_05_33_58 = 1765863238
+ super(&block)
+ end
+
+ def build_array
+ data_type = Arrow::TimestampDataType.new(:second, @time_zone)
+ Arrow::TimestampArray.new(data_type,
+ [
+ @timestamp_2019_11_17_15_09_11,
+ nil,
+ @timestamp_2025_12_16_05_33_58,
+ ])
+ end
+
+ def test_type
+ assert_equal([Arrow::TimeUnit::SECOND, @time_zone],
+ [@type.unit, @type.time_zone&.identifier])
Review Comment:
`@type` correct? Is this my environment issue?
```
LD_LIBRARY_PATH=/tmp/local/lib:/path/to/arrow/red-arrow/ext/arrow/ GI_TYPELIB_PATH=/tmp/local/lib/girepository-1.0 rake -I /path/to/arrow/ruby/red-arrow/lib test
cd /path/to/arrow/ruby/red-arrow-format
/path/to/.rbenv/versions/3.4.7/bin/ruby test/run.rb
Loaded suite test
Started
/path/to/arrow/ruby/red-arrow-format/lib/arrow-format/file-reader.rb:40: warning: IO::Buffer is experimental and both the Ruby and C interface may change in the future!
F
==============================================================================================================================================================================
Failure: test_type(TestFileWriter::Timestamp(time_zone))
/path/to/arrow/ruby/red-arrow-format/test/test-writer.rb:515:in 'test_type'
512: end
513:
514: def test_type
=> 515: assert_equal([Arrow::TimeUnit::SECOND, @time_zone],
516: [@type.unit, @type.time_zone&.identifier])
517: end
518: end
<[#<Arrow::TimeUnit second>, "UTC"]> expected but was
<[#<Arrow::TimeUnit second>, nil]>
diff:
? [#<Arrow::TimeUnit second>, "UTC"]
? nil
? ?????
==============================================================================================================================================================================
F
==============================================================================================================================================================================
Failure: test_type(TestStreamingWriter::Timestamp(time_zone))
/path/to/arrow/ruby/red-arrow-format/test/test-writer.rb:515:in 'test_type'
512: end
513:
514: def test_type
=> 515: assert_equal([Arrow::TimeUnit::SECOND, @time_zone],
516: [@type.unit, @type.time_zone&.identifier])
517: end
518: end
<[#<Arrow::TimeUnit second>, "UTC"]> expected but was
<[#<Arrow::TimeUnit second>, nil]>
diff:
? [#<Arrow::TimeUnit second>, "UTC"]
? nil
? ?????
==============================================================================================================================================================================
Finished in 1.756426992 seconds.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
160 tests, 160 assertions, 2 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
98.75% passed
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
91.09 tests/s, 91.09 assertions/s
rake aborted!
Command failed with status (1): [/path/to/.rbenv/versions/3.4.7/bin/ruby test/run.rb]
/path/to/arrow/ruby/red-arrow-format/Rakefile:38:in 'block (2 levels) in <top (required)>'
/path/to/arrow/ruby/red-arrow-format/Rakefile:37:in 'block in <top (required)>'
Tasks: TOP => test
(See full trace by running task with --trace)
```
--
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