hiroyuki-sato commented on code in PR #48554:
URL: https://github.com/apache/arrow/pull/48554#discussion_r2622897501
##########
ruby/red-arrow-format/test/test-file-reader.rb:
##########
@@ -323,6 +339,154 @@ def test_read
],
read)
end
+
+ def test_type
+ assert_equal(:nanosecond, type.unit)
+ end
+ end
+
+ sub_test_case("Timestamp(:second)") do
+ def setup(&block)
+ @timestamp_2019_11_18_00_09_11 = 1574003351
+ @timestamp_2025_12_16_05_33_58 = 1765863238
Review Comment:
```suggestion
@timestamp_2025_12_16_05_33_58 = 1765830838
```
```
[6] pry(main)> Time.new(2025,12,16,5,33,58).to_i
=> 1765830838
```
##########
ruby/red-arrow-format/test/test-file-reader.rb:
##########
@@ -323,6 +339,154 @@ def test_read
],
read)
end
+
+ def test_type
+ assert_equal(:nanosecond, type.unit)
+ end
+ end
+
+ sub_test_case("Timestamp(:second)") do
+ def setup(&block)
+ @timestamp_2019_11_18_00_09_11 = 1574003351
+ @timestamp_2025_12_16_05_33_58 = 1765863238
+ super(&block)
+ end
+
+ def build_array
+ Arrow::TimestampArray.new(:second,
+ [
+ @timestamp_2019_11_18_00_09_11,
+ nil,
+ @timestamp_2025_12_16_05_33_58,
+ ])
+ end
+
+ def test_read
+ assert_equal([
+ {
+ "value" => [
+ @timestamp_2019_11_18_00_09_11,
+ nil,
+ @timestamp_2025_12_16_05_33_58,
+ ],
+ },
+ ],
+ read)
+ end
+ end
+
+ sub_test_case("Timestamp(:millisecond)") do
+ def setup(&block)
+ @timestamp_2019_11_18_00_09_11 = 1574003351 * 1_000
+ @timestamp_2025_12_16_05_33_58 = 1765863238 * 1_000
+ super(&block)
+ end
+
+ def build_array
+ Arrow::TimestampArray.new(:second,
+ [
+ @timestamp_2019_11_18_00_09_11,
+ nil,
+ @timestamp_2025_12_16_05_33_58,
+ ])
+ end
+
+ def test_read
+ assert_equal([
+ {
+ "value" => [
+ @timestamp_2019_11_18_00_09_11,
+ nil,
+ @timestamp_2025_12_16_05_33_58,
+ ],
+ },
+ ],
+ read)
+ end
+ end
+
+ sub_test_case("Timestamp(:microsecond)") do
+ def setup(&block)
+ @timestamp_2019_11_18_00_09_11 = 1574003351 * 1_000_000
+ @timestamp_2025_12_16_05_33_58 = 1765863238 * 1_000_000
Review Comment:
```suggestion
@timestamp_2025_12_16_05_33_58 = 1765830838 * 1_000_000
```
```
[6] pry(main)> Time.new(2025,12,16,5,33,58).to_i
=> 1765830838
```
##########
ruby/red-arrow-format/lib/arrow-format/type.rb:
##########
@@ -289,15 +293,28 @@ def build_array(size, validity_buffer, values_buffer)
class Time64Type < TimeType
def initialize(unit)
- super("Time64")
- @unit = unit
+ super("Time64", unit)
end
def build_array(size, validity_buffer, values_buffer)
Time64Array.new(self, size, validity_buffer, values_buffer)
end
end
+ class TimestampType < TemporalType
+ attr_reader :unit
+ attr_reader :timezone
+ def initialize(unit, timezone)
+ super("Temporal")
Review Comment:
Is this correct? `super("Timestamp")`?
##########
ruby/red-arrow-format/test/test-file-reader.rb:
##########
@@ -323,6 +339,154 @@ def test_read
],
read)
end
+
+ def test_type
+ assert_equal(:nanosecond, type.unit)
+ end
+ end
+
+ sub_test_case("Timestamp(:second)") do
+ def setup(&block)
+ @timestamp_2019_11_18_00_09_11 = 1574003351
+ @timestamp_2025_12_16_05_33_58 = 1765863238
+ super(&block)
+ end
+
+ def build_array
+ Arrow::TimestampArray.new(:second,
+ [
+ @timestamp_2019_11_18_00_09_11,
+ nil,
+ @timestamp_2025_12_16_05_33_58,
+ ])
+ end
+
+ def test_read
+ assert_equal([
+ {
+ "value" => [
+ @timestamp_2019_11_18_00_09_11,
+ nil,
+ @timestamp_2025_12_16_05_33_58,
+ ],
+ },
+ ],
+ read)
+ end
+ end
+
+ sub_test_case("Timestamp(:millisecond)") do
+ def setup(&block)
+ @timestamp_2019_11_18_00_09_11 = 1574003351 * 1_000
+ @timestamp_2025_12_16_05_33_58 = 1765863238 * 1_000
+ super(&block)
+ end
+
+ def build_array
+ Arrow::TimestampArray.new(:second,
+ [
+ @timestamp_2019_11_18_00_09_11,
+ nil,
+ @timestamp_2025_12_16_05_33_58,
+ ])
+ end
+
+ def test_read
+ assert_equal([
+ {
+ "value" => [
+ @timestamp_2019_11_18_00_09_11,
+ nil,
+ @timestamp_2025_12_16_05_33_58,
+ ],
+ },
+ ],
+ read)
+ end
+ end
+
+ sub_test_case("Timestamp(:microsecond)") do
+ def setup(&block)
+ @timestamp_2019_11_18_00_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(:second,
Review Comment:
```suggestion
Arrow::TimestampArray.new(:micro,
```
##########
ruby/red-arrow-format/test/test-file-reader.rb:
##########
@@ -323,6 +339,154 @@ def test_read
],
read)
end
+
+ def test_type
+ assert_equal(:nanosecond, type.unit)
+ end
+ end
+
+ sub_test_case("Timestamp(:second)") do
+ def setup(&block)
+ @timestamp_2019_11_18_00_09_11 = 1574003351
+ @timestamp_2025_12_16_05_33_58 = 1765863238
+ super(&block)
+ end
+
+ def build_array
+ Arrow::TimestampArray.new(:second,
+ [
+ @timestamp_2019_11_18_00_09_11,
+ nil,
+ @timestamp_2025_12_16_05_33_58,
+ ])
+ end
+
+ def test_read
+ assert_equal([
+ {
+ "value" => [
+ @timestamp_2019_11_18_00_09_11,
+ nil,
+ @timestamp_2025_12_16_05_33_58,
+ ],
+ },
+ ],
+ read)
+ end
+ end
+
+ sub_test_case("Timestamp(:millisecond)") do
+ def setup(&block)
+ @timestamp_2019_11_18_00_09_11 = 1574003351 * 1_000
+ @timestamp_2025_12_16_05_33_58 = 1765863238 * 1_000
+ super(&block)
+ end
+
+ def build_array
+ Arrow::TimestampArray.new(:second,
Review Comment:
```suggestion
Arrow::TimestampArray.new(:milli,
```
##########
ruby/red-arrow-format/test/test-file-reader.rb:
##########
@@ -323,6 +339,154 @@ def test_read
],
read)
end
+
+ def test_type
+ assert_equal(:nanosecond, type.unit)
+ end
+ end
+
+ sub_test_case("Timestamp(:second)") do
+ def setup(&block)
+ @timestamp_2019_11_18_00_09_11 = 1574003351
+ @timestamp_2025_12_16_05_33_58 = 1765863238
+ super(&block)
+ end
+
+ def build_array
+ Arrow::TimestampArray.new(:second,
+ [
+ @timestamp_2019_11_18_00_09_11,
+ nil,
+ @timestamp_2025_12_16_05_33_58,
+ ])
+ end
+
+ def test_read
+ assert_equal([
+ {
+ "value" => [
+ @timestamp_2019_11_18_00_09_11,
+ nil,
+ @timestamp_2025_12_16_05_33_58,
+ ],
+ },
+ ],
+ read)
+ end
+ end
+
+ sub_test_case("Timestamp(:millisecond)") do
+ def setup(&block)
+ @timestamp_2019_11_18_00_09_11 = 1574003351 * 1_000
+ @timestamp_2025_12_16_05_33_58 = 1765863238 * 1_000
Review Comment:
```suggestion
@timestamp_2025_12_16_05_33_58 = 1765830838 * 1_000
```
```
[6] pry(main)> Time.new(2025,12,16,5,33,58).to_i
=> 1765830838
```
##########
ruby/red-arrow-format/test/test-file-reader.rb:
##########
@@ -323,6 +339,154 @@ def test_read
],
read)
end
+
+ def test_type
+ assert_equal(:nanosecond, type.unit)
+ end
+ end
+
+ sub_test_case("Timestamp(:second)") do
+ def setup(&block)
+ @timestamp_2019_11_18_00_09_11 = 1574003351
+ @timestamp_2025_12_16_05_33_58 = 1765863238
+ super(&block)
+ end
+
+ def build_array
+ Arrow::TimestampArray.new(:second,
+ [
+ @timestamp_2019_11_18_00_09_11,
+ nil,
+ @timestamp_2025_12_16_05_33_58,
+ ])
+ end
+
+ def test_read
+ assert_equal([
+ {
+ "value" => [
+ @timestamp_2019_11_18_00_09_11,
+ nil,
+ @timestamp_2025_12_16_05_33_58,
+ ],
+ },
+ ],
+ read)
+ end
+ end
+
+ sub_test_case("Timestamp(:millisecond)") do
+ def setup(&block)
+ @timestamp_2019_11_18_00_09_11 = 1574003351 * 1_000
+ @timestamp_2025_12_16_05_33_58 = 1765863238 * 1_000
+ super(&block)
+ end
+
+ def build_array
+ Arrow::TimestampArray.new(:second,
+ [
+ @timestamp_2019_11_18_00_09_11,
+ nil,
+ @timestamp_2025_12_16_05_33_58,
+ ])
+ end
+
+ def test_read
+ assert_equal([
+ {
+ "value" => [
+ @timestamp_2019_11_18_00_09_11,
+ nil,
+ @timestamp_2025_12_16_05_33_58,
+ ],
+ },
+ ],
+ read)
+ end
+ end
+
+ sub_test_case("Timestamp(:microsecond)") do
+ def setup(&block)
+ @timestamp_2019_11_18_00_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(:second,
+ [
+ @timestamp_2019_11_18_00_09_11,
+ nil,
+ @timestamp_2025_12_16_05_33_58,
+ ])
+ end
+
+ def test_read
+ assert_equal([
+ {
+ "value" => [
+ @timestamp_2019_11_18_00_09_11,
+ nil,
+ @timestamp_2025_12_16_05_33_58,
+ ],
+ },
+ ],
+ read)
+ end
+ end
+
+ sub_test_case("Timestamp(:nanosecond)") do
+ def setup(&block)
+ @timestamp_2019_11_18_00_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(:second,
+ [
+ @timestamp_2019_11_18_00_09_11,
+ nil,
+ @timestamp_2025_12_16_05_33_58,
+ ])
+ end
+
+ def test_read
+ assert_equal([
+ {
+ "value" => [
+ @timestamp_2019_11_18_00_09_11,
+ nil,
+ @timestamp_2025_12_16_05_33_58,
+ ],
+ },
+ ],
+ read)
+ end
+ end
+
+ sub_test_case("Timestamp(timezone)") do
+ def setup(&block)
+ @timezone = "UTC"
+ @timestamp_2019_11_18_00_09_11 = 1574003351
+ @timestamp_2025_12_16_05_33_58 = 1765863238
Review Comment:
```suggestion
@timestamp_2025_12_16_05_33_58 = 1765830838
```
```
[6] pry(main)> Time.new(2025,12,16,5,33,58).to_i
=> 1765830838
```
##########
ruby/red-arrow-format/test/test-file-reader.rb:
##########
@@ -323,6 +339,154 @@ def test_read
],
read)
end
+
+ def test_type
+ assert_equal(:nanosecond, type.unit)
+ end
+ end
+
+ sub_test_case("Timestamp(:second)") do
+ def setup(&block)
+ @timestamp_2019_11_18_00_09_11 = 1574003351
+ @timestamp_2025_12_16_05_33_58 = 1765863238
+ super(&block)
+ end
+
+ def build_array
+ Arrow::TimestampArray.new(:second,
+ [
+ @timestamp_2019_11_18_00_09_11,
+ nil,
+ @timestamp_2025_12_16_05_33_58,
+ ])
+ end
+
+ def test_read
+ assert_equal([
+ {
+ "value" => [
+ @timestamp_2019_11_18_00_09_11,
+ nil,
+ @timestamp_2025_12_16_05_33_58,
+ ],
+ },
+ ],
+ read)
+ end
+ end
+
+ sub_test_case("Timestamp(:millisecond)") do
+ def setup(&block)
+ @timestamp_2019_11_18_00_09_11 = 1574003351 * 1_000
+ @timestamp_2025_12_16_05_33_58 = 1765863238 * 1_000
+ super(&block)
+ end
+
+ def build_array
+ Arrow::TimestampArray.new(:second,
+ [
+ @timestamp_2019_11_18_00_09_11,
+ nil,
+ @timestamp_2025_12_16_05_33_58,
+ ])
+ end
+
+ def test_read
+ assert_equal([
+ {
+ "value" => [
+ @timestamp_2019_11_18_00_09_11,
+ nil,
+ @timestamp_2025_12_16_05_33_58,
+ ],
+ },
+ ],
+ read)
+ end
+ end
+
+ sub_test_case("Timestamp(:microsecond)") do
+ def setup(&block)
+ @timestamp_2019_11_18_00_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(:second,
+ [
+ @timestamp_2019_11_18_00_09_11,
+ nil,
+ @timestamp_2025_12_16_05_33_58,
+ ])
+ end
+
+ def test_read
+ assert_equal([
+ {
+ "value" => [
+ @timestamp_2019_11_18_00_09_11,
+ nil,
+ @timestamp_2025_12_16_05_33_58,
+ ],
+ },
+ ],
+ read)
+ end
+ end
+
+ sub_test_case("Timestamp(:nanosecond)") do
+ def setup(&block)
+ @timestamp_2019_11_18_00_09_11 = 1574003351 * 1_000_000_000
+ @timestamp_2025_12_16_05_33_58 = 1765863238 * 1_000_000_000
Review Comment:
```suggestion
@timestamp_2025_12_16_05_33_58 = 1765830838 * 1_000_000_000
```
```
[6] pry(main)> Time.new(2025,12,16,5,33,58).to_i
=> 1765830838
```
##########
ruby/red-arrow-format/test/test-file-reader.rb:
##########
@@ -323,6 +339,154 @@ def test_read
],
read)
end
+
+ def test_type
+ assert_equal(:nanosecond, type.unit)
+ end
+ end
+
+ sub_test_case("Timestamp(:second)") do
+ def setup(&block)
+ @timestamp_2019_11_18_00_09_11 = 1574003351
+ @timestamp_2025_12_16_05_33_58 = 1765863238
+ super(&block)
+ end
+
+ def build_array
+ Arrow::TimestampArray.new(:second,
+ [
+ @timestamp_2019_11_18_00_09_11,
+ nil,
+ @timestamp_2025_12_16_05_33_58,
+ ])
+ end
+
+ def test_read
+ assert_equal([
+ {
+ "value" => [
+ @timestamp_2019_11_18_00_09_11,
+ nil,
+ @timestamp_2025_12_16_05_33_58,
+ ],
+ },
+ ],
+ read)
+ end
+ end
+
+ sub_test_case("Timestamp(:millisecond)") do
+ def setup(&block)
+ @timestamp_2019_11_18_00_09_11 = 1574003351 * 1_000
+ @timestamp_2025_12_16_05_33_58 = 1765863238 * 1_000
+ super(&block)
+ end
+
+ def build_array
+ Arrow::TimestampArray.new(:second,
+ [
+ @timestamp_2019_11_18_00_09_11,
+ nil,
+ @timestamp_2025_12_16_05_33_58,
+ ])
+ end
+
+ def test_read
+ assert_equal([
+ {
+ "value" => [
+ @timestamp_2019_11_18_00_09_11,
+ nil,
+ @timestamp_2025_12_16_05_33_58,
+ ],
+ },
+ ],
+ read)
+ end
+ end
+
+ sub_test_case("Timestamp(:microsecond)") do
+ def setup(&block)
+ @timestamp_2019_11_18_00_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(:second,
+ [
+ @timestamp_2019_11_18_00_09_11,
+ nil,
+ @timestamp_2025_12_16_05_33_58,
+ ])
+ end
+
+ def test_read
+ assert_equal([
+ {
+ "value" => [
+ @timestamp_2019_11_18_00_09_11,
+ nil,
+ @timestamp_2025_12_16_05_33_58,
+ ],
+ },
+ ],
+ read)
+ end
+ end
+
+ sub_test_case("Timestamp(:nanosecond)") do
+ def setup(&block)
+ @timestamp_2019_11_18_00_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(:second,
Review Comment:
```suggestion
Arrow::TimestampArray.new(:nano,
```
--
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]