Skip to content
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

GH-40153: [C++][Python] Fix test_gdb failures on 32-bit #40293

Merged
merged 1 commit into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cpp/gdb_arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,8 @@ def format_timestamp(val, unit):
seconds, subseconds = divmod(val, traits.multiplier)
try:
dt = datetime.datetime.utcfromtimestamp(seconds)
except (ValueError, OSError): # value out of range for datetime.datetime
except (ValueError, OSError, OverflowError):
# value out of range for datetime.datetime
pretty = "too large to represent"
else:
pretty = dt.isoformat().replace('T', ' ')
Expand Down
81 changes: 55 additions & 26 deletions python/pyarrow/tests/test_gdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -885,32 +885,61 @@ def test_arrays_heap(gdb_arrow):
("arrow::DurationArray of type arrow::duration"
"(arrow::TimeUnit::NANO), length 2, offset 0, null count 1 = {"
"[0] = null, [1] = -1234567890123456789ns}"))
check_heap_repr(
gdb_arrow, "heap_timestamp_array_s",
("arrow::TimestampArray of type arrow::timestamp"
"(arrow::TimeUnit::SECOND), length 4, offset 0, null count 1 = {"
"[0] = null, [1] = 0s [1970-01-01 00:00:00], "
"[2] = -2203932304s [1900-02-28 12:34:56], "
"[3] = 63730281600s [3989-07-14 00:00:00]}"))
check_heap_repr(
gdb_arrow, "heap_timestamp_array_ms",
("arrow::TimestampArray of type arrow::timestamp"
"(arrow::TimeUnit::MILLI), length 3, offset 0, null count 1 = {"
"[0] = null, [1] = -2203932303877ms [1900-02-28 12:34:56.123], "
"[2] = 63730281600789ms [3989-07-14 00:00:00.789]}"))
check_heap_repr(
gdb_arrow, "heap_timestamp_array_us",
("arrow::TimestampArray of type arrow::timestamp"
"(arrow::TimeUnit::MICRO), length 3, offset 0, null count 1 = {"
"[0] = null, "
"[1] = -2203932303345679us [1900-02-28 12:34:56.654321], "
"[2] = 63730281600456789us [3989-07-14 00:00:00.456789]}"))
check_heap_repr(
gdb_arrow, "heap_timestamp_array_ns",
("arrow::TimestampArray of type arrow::timestamp"
"(arrow::TimeUnit::NANO), length 2, offset 0, null count 1 = {"
"[0] = null, "
"[1] = -2203932303012345679ns [1900-02-28 12:34:56.987654321]}"))
if sys.maxsize > 2**32:
check_heap_repr(
gdb_arrow, "heap_timestamp_array_s",
("arrow::TimestampArray of type arrow::timestamp"
"(arrow::TimeUnit::SECOND), length 4, offset 0, null count 1 = {"
"[0] = null, [1] = 0s [1970-01-01 00:00:00], "
"[2] = -2203932304s [1900-02-28 12:34:56], "
"[3] = 63730281600s [3989-07-14 00:00:00]}"))
check_heap_repr(
gdb_arrow, "heap_timestamp_array_ms",
("arrow::TimestampArray of type arrow::timestamp"
"(arrow::TimeUnit::MILLI), length 3, offset 0, null count 1 = {"
"[0] = null, [1] = -2203932303877ms [1900-02-28 12:34:56.123], "
"[2] = 63730281600789ms [3989-07-14 00:00:00.789]}"))
check_heap_repr(
gdb_arrow, "heap_timestamp_array_us",
("arrow::TimestampArray of type arrow::timestamp"
"(arrow::TimeUnit::MICRO), length 3, offset 0, null count 1 = {"
"[0] = null, "
"[1] = -2203932303345679us [1900-02-28 12:34:56.654321], "
"[2] = 63730281600456789us [3989-07-14 00:00:00.456789]}"))
check_heap_repr(
gdb_arrow, "heap_timestamp_array_ns",
("arrow::TimestampArray of type arrow::timestamp"
"(arrow::TimeUnit::NANO), length 2, offset 0, null count 1 = {"
"[0] = null, "
"[1] = -2203932303012345679ns [1900-02-28 12:34:56.987654321]}"))
else:
# Python's datetime is limited to smaller timestamps on 32-bit platforms
check_heap_repr(
gdb_arrow, "heap_timestamp_array_s",
("arrow::TimestampArray of type arrow::timestamp"
"(arrow::TimeUnit::SECOND), length 4, offset 0, null count 1 = {"
"[0] = null, [1] = 0s [1970-01-01 00:00:00], "
"[2] = -2203932304s [too large to represent], "
"[3] = 63730281600s [too large to represent]}"))
check_heap_repr(
gdb_arrow, "heap_timestamp_array_ms",
("arrow::TimestampArray of type arrow::timestamp"
"(arrow::TimeUnit::MILLI), length 3, offset 0, null count 1 = {"
"[0] = null, [1] = -2203932303877ms [too large to represent], "
"[2] = 63730281600789ms [too large to represent]}"))
check_heap_repr(
gdb_arrow, "heap_timestamp_array_us",
("arrow::TimestampArray of type arrow::timestamp"
"(arrow::TimeUnit::MICRO), length 3, offset 0, null count 1 = {"
"[0] = null, "
"[1] = -2203932303345679us [too large to represent], "
"[2] = 63730281600456789us [too large to represent]}"))
check_heap_repr(
gdb_arrow, "heap_timestamp_array_ns",
("arrow::TimestampArray of type arrow::timestamp"
"(arrow::TimeUnit::NANO), length 2, offset 0, null count 1 = {"
"[0] = null, "
"[1] = -2203932303012345679ns [too large to represent]}"))

# Decimal
check_heap_repr(
Expand Down
Loading