-
Notifications
You must be signed in to change notification settings - Fork 4k
GH-48553: [Ruby] Add support for reading timestamp array #48554
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -40,6 +40,10 @@ def read | |||||
| end | ||||||
| end | ||||||
|
|
||||||
| def type | ||||||
| @type ||= @reader.first.schema.fields[0].type | ||||||
| end | ||||||
|
|
||||||
| sub_test_case("Null") do | ||||||
| def build_array | ||||||
| Arrow::NullArray.new(3) | ||||||
|
|
@@ -245,6 +249,10 @@ def test_read | |||||
| assert_equal([{"value" => [@time_00_00_10, nil, @time_00_01_10]}], | ||||||
| read) | ||||||
| end | ||||||
|
|
||||||
| def test_type | ||||||
| assert_equal(:second, type.unit) | ||||||
| end | ||||||
| end | ||||||
|
|
||||||
| sub_test_case("Time32(:millisecond)") do | ||||||
|
|
@@ -263,6 +271,10 @@ def test_read | |||||
| assert_equal([{"value" => [@time_00_00_10_000, nil, @time_00_01_10_000]}], | ||||||
| read) | ||||||
| end | ||||||
|
|
||||||
| def test_type | ||||||
| assert_equal(:millisecond, type.unit) | ||||||
| end | ||||||
| end | ||||||
|
|
||||||
| sub_test_case("Time64(:microsecond)") do | ||||||
|
|
@@ -293,6 +305,10 @@ def test_read | |||||
| ], | ||||||
| read) | ||||||
| end | ||||||
|
|
||||||
| def test_type | ||||||
| assert_equal(:microsecond, type.unit) | ||||||
| end | ||||||
| end | ||||||
|
|
||||||
| sub_test_case("Time64(:nanosecond)") do | ||||||
|
|
@@ -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 | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| super(&block) | ||||||
| end | ||||||
|
|
||||||
| def build_array | ||||||
| Arrow::TimestampArray.new(:milli, | ||||||
| [ | ||||||
| @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 | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| super(&block) | ||||||
| end | ||||||
|
|
||||||
| def build_array | ||||||
| Arrow::TimestampArray.new(:micro, | ||||||
| [ | ||||||
| @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 | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| super(&block) | ||||||
| end | ||||||
|
|
||||||
| def build_array | ||||||
| Arrow::TimestampArray.new(:nano, | ||||||
| [ | ||||||
| @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 | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| super(&block) | ||||||
| end | ||||||
|
|
||||||
| def build_array | ||||||
| data_type = Arrow::TimestampDataType.new(:second, @timezone) | ||||||
| Arrow::TimestampArray.new(data_type, | ||||||
| [ | ||||||
| @timestamp_2019_11_18_00_09_11, | ||||||
| nil, | ||||||
| @timestamp_2025_12_16_05_33_58, | ||||||
| ]) | ||||||
| end | ||||||
|
|
||||||
| def test_type | ||||||
| assert_equal([:second, @timezone], | ||||||
| [type.unit, type.timezone]) | ||||||
| end | ||||||
| end | ||||||
|
|
||||||
| sub_test_case("Binary") do | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.