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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]