Skip to content

Commit 11012a9

Browse files
committed
apacheGH-40153: [C++][Python] Fix test_gdb failures on 32-bit
1 parent d3ae788 commit 11012a9

File tree

2 files changed

+57
-27
lines changed

2 files changed

+57
-27
lines changed

cpp/gdb_arrow.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,8 @@ def format_timestamp(val, unit):
304304
seconds, subseconds = divmod(val, traits.multiplier)
305305
try:
306306
dt = datetime.datetime.utcfromtimestamp(seconds)
307-
except (ValueError, OSError): # value out of range for datetime.datetime
307+
except (ValueError, OSError, OverflowError):
308+
# value out of range for datetime.datetime
308309
pretty = "too large to represent"
309310
else:
310311
pretty = dt.isoformat().replace('T', ' ')

python/pyarrow/tests/test_gdb.py

+55-26
Original file line numberDiff line numberDiff line change
@@ -885,32 +885,61 @@ def test_arrays_heap(gdb_arrow):
885885
("arrow::DurationArray of type arrow::duration"
886886
"(arrow::TimeUnit::NANO), length 2, offset 0, null count 1 = {"
887887
"[0] = null, [1] = -1234567890123456789ns}"))
888-
check_heap_repr(
889-
gdb_arrow, "heap_timestamp_array_s",
890-
("arrow::TimestampArray of type arrow::timestamp"
891-
"(arrow::TimeUnit::SECOND), length 4, offset 0, null count 1 = {"
892-
"[0] = null, [1] = 0s [1970-01-01 00:00:00], "
893-
"[2] = -2203932304s [1900-02-28 12:34:56], "
894-
"[3] = 63730281600s [3989-07-14 00:00:00]}"))
895-
check_heap_repr(
896-
gdb_arrow, "heap_timestamp_array_ms",
897-
("arrow::TimestampArray of type arrow::timestamp"
898-
"(arrow::TimeUnit::MILLI), length 3, offset 0, null count 1 = {"
899-
"[0] = null, [1] = -2203932303877ms [1900-02-28 12:34:56.123], "
900-
"[2] = 63730281600789ms [3989-07-14 00:00:00.789]}"))
901-
check_heap_repr(
902-
gdb_arrow, "heap_timestamp_array_us",
903-
("arrow::TimestampArray of type arrow::timestamp"
904-
"(arrow::TimeUnit::MICRO), length 3, offset 0, null count 1 = {"
905-
"[0] = null, "
906-
"[1] = -2203932303345679us [1900-02-28 12:34:56.654321], "
907-
"[2] = 63730281600456789us [3989-07-14 00:00:00.456789]}"))
908-
check_heap_repr(
909-
gdb_arrow, "heap_timestamp_array_ns",
910-
("arrow::TimestampArray of type arrow::timestamp"
911-
"(arrow::TimeUnit::NANO), length 2, offset 0, null count 1 = {"
912-
"[0] = null, "
913-
"[1] = -2203932303012345679ns [1900-02-28 12:34:56.987654321]}"))
888+
if sys.maxsize > 2**32:
889+
check_heap_repr(
890+
gdb_arrow, "heap_timestamp_array_s",
891+
("arrow::TimestampArray of type arrow::timestamp"
892+
"(arrow::TimeUnit::SECOND), length 4, offset 0, null count 1 = {"
893+
"[0] = null, [1] = 0s [1970-01-01 00:00:00], "
894+
"[2] = -2203932304s [1900-02-28 12:34:56], "
895+
"[3] = 63730281600s [3989-07-14 00:00:00]}"))
896+
check_heap_repr(
897+
gdb_arrow, "heap_timestamp_array_ms",
898+
("arrow::TimestampArray of type arrow::timestamp"
899+
"(arrow::TimeUnit::MILLI), length 3, offset 0, null count 1 = {"
900+
"[0] = null, [1] = -2203932303877ms [1900-02-28 12:34:56.123], "
901+
"[2] = 63730281600789ms [3989-07-14 00:00:00.789]}"))
902+
check_heap_repr(
903+
gdb_arrow, "heap_timestamp_array_us",
904+
("arrow::TimestampArray of type arrow::timestamp"
905+
"(arrow::TimeUnit::MICRO), length 3, offset 0, null count 1 = {"
906+
"[0] = null, "
907+
"[1] = -2203932303345679us [1900-02-28 12:34:56.654321], "
908+
"[2] = 63730281600456789us [3989-07-14 00:00:00.456789]}"))
909+
check_heap_repr(
910+
gdb_arrow, "heap_timestamp_array_ns",
911+
("arrow::TimestampArray of type arrow::timestamp"
912+
"(arrow::TimeUnit::NANO), length 2, offset 0, null count 1 = {"
913+
"[0] = null, "
914+
"[1] = -2203932303012345679ns [1900-02-28 12:34:56.987654321]}"))
915+
else:
916+
# Python's datetime is limited to smaller timestamps on 32-bit platforms
917+
check_heap_repr(
918+
gdb_arrow, "heap_timestamp_array_s",
919+
("arrow::TimestampArray of type arrow::timestamp"
920+
"(arrow::TimeUnit::SECOND), length 4, offset 0, null count 1 = {"
921+
"[0] = null, [1] = 0s [1970-01-01 00:00:00], "
922+
"[2] = -2203932304s [too large to represent], "
923+
"[3] = 63730281600s [too large to represent]}"))
924+
check_heap_repr(
925+
gdb_arrow, "heap_timestamp_array_ms",
926+
("arrow::TimestampArray of type arrow::timestamp"
927+
"(arrow::TimeUnit::MILLI), length 3, offset 0, null count 1 = {"
928+
"[0] = null, [1] = -2203932303877ms [too large to represent], "
929+
"[2] = 63730281600789ms [too large to represent]}"))
930+
check_heap_repr(
931+
gdb_arrow, "heap_timestamp_array_us",
932+
("arrow::TimestampArray of type arrow::timestamp"
933+
"(arrow::TimeUnit::MICRO), length 3, offset 0, null count 1 = {"
934+
"[0] = null, "
935+
"[1] = -2203932303345679us [too large to represent], "
936+
"[2] = 63730281600456789us [too large to represent]}"))
937+
check_heap_repr(
938+
gdb_arrow, "heap_timestamp_array_ns",
939+
("arrow::TimestampArray of type arrow::timestamp"
940+
"(arrow::TimeUnit::NANO), length 2, offset 0, null count 1 = {"
941+
"[0] = null, "
942+
"[1] = -2203932303012345679ns [too large to represent]}"))
914943

915944
# Decimal
916945
check_heap_repr(

0 commit comments

Comments
 (0)