You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Python] error raised for TimestampScalar.__repr__() when timezone is set using offset "+00:00" #47043
A valid pyarrow.TimestampScalar value throws an error when its .__repr__() is called. This is specific to when timezones are specified as offsets +07:30. It doesn't occur with IANA "America/New_York" and UTC-like "UTC".
Asking the docs chatbot What are the valid ways to specify the timezone of a timestamp value? suggests that IANA, UTC, and offsets are valid options. They are the supported conventiosn in C++ TimestampType and Python pyarrow.timestamp
Background
This bug was initially found via pyarrow.csv.CSVWriter().write() in the library Python dlt.
I initially thought it was related to the Python library ConnectorX which recently changed Rust backend from arrow2 to arrow (issue)
Collaborating with Connectorx maintainers, we noticed that TimestampScalar.__str__() and TimestampScalar.__repr__() behaved differently
With this new knowledge, I will have to go back to dlt code for debugging. It's possible that there's no bug with the CSVWriter and what I encountered was the product of using the Python debugger to do the connector-x upgrade.
changed the title [-][Python] error raised for `TimestampScalar.__repr__()` when timezone is set using format `+00`[/-][+][Python] error raised for `TimestampScalar.__repr__()` when timezone is set using offset `"+00:00"`[/+]on Jul 9, 2025
As a workaroud you can use "Etc/GMT+1" format that is a valid TZ identifier (this will cover only full hour offsets AFAIK).
We discussed and agreed Arrow should support offsets ([1][2]). I seem to have a stale PR for this that I could complete at some point or hand it over to someone.
@rok Thanks for the quick reply! Indeed, supporting offsets would be useful.
I'm a maintainer for the Python library dlt and my practical goal is to be able to use connector-x as a dependency. This library uses the Rust crate arrow and brings significant performance improvements.
The time zone is a string indicating the name of a time zone, one of:
As used in the Olson time zone database (the “tz database” or “tzdata”), such as “America/New_York”
An absolute time zone offset of the form +XX:XX or -XX:XX, such as +07:30
(i.e., it doesn't support UTC)
They switched to offset-based timezones, which solved their bug, but created downstream issues for some dlt users.
Given what you know, do you think that connector-x adopting tzdata format instead of offsets or UTC could be a lasting solution? For instance, Africa/Bissau seems to match UTC or +00:00 (could be facing daylight saving time issues?). Alternatively, I could modify dlt code to any +00:00 offsets into UTC
I'm a maintainer for the Python library dlt and my practical goal is to be able to use connector-x as a dependency. This library uses the Rust crate arrow and brings significant performance improvements.
Please note arrow-rs has a separate issue tracker, while here we now mostly track C++ implementation and it's wrappers. I am not intimately familiar with the rust implementation so perhaps you want to ask there too.
Given what you know, do you think that connector-x adopting tzdata format instead of offsets or UTC could be a lasting solution? For instance, Africa/Bissau seems to match UTC or +00:00 (could be facing daylight saving time issues?). Alternatively, I could modify dlt code to any +00:00 offsets into UTC
As far as I know UTC, Etc/UCT, Etc/GMT, Etc/GMT+X, Etc/GMT-X are all valid timezones that are equivalent to +/-XX:00 offsets. As long as you don't need +/-XX:30 offsets (I don't know why this is a thing) and logic for mapping offset strings into offset timezones (e.g. -10:00 => Etc/GMT-10:00) can be put somewhere this should imo be a lasting solution. Probably it'd be better if we didn't use offsets at all, but that is probably not a realistic option.
timezones can be specified in various ways (offset, iana); the Arrow specs intend to support all of them
all formats supported in pyarrow, but some specific features don't support offset-based time zones (e.g., "+01:00").
For example, pyarrow._csv.CSVWriter(...).write() or pyarrow.TimeScalar(...).__repr__()
You're unlikely to face these issues when using pyarrow (Arrow C) because it doesn't default to offset-based timestamps. However, other arrow implementations (e.g., Arrow Rust) may default to using them
Issue
For follow-up, I pinned down my issue to this problem:
Activity
[-][Python] error raised for `TimestampScalar.__repr__()` when timezone is set using format `+00`[/-][+][Python] error raised for `TimestampScalar.__repr__()` when timezone is set using offset `"+00:00"`[/+]rok commentedon Jul 9, 2025
Hi @zilto, thanks for the generous research and report!
This behavior is due to date.h (upstream library we use for timezone logic) not supporting offsets.
As a workaroud you can use
"Etc/GMT+1"format that is a valid TZ identifier (this will cover only full hour offsets AFAIK).We discussed and agreed Arrow should support offsets ([1] [2]). I seem to have a stale PR for this that I could complete at some point or hand it over to someone.
zilto commentedon Jul 9, 2025
@rok Thanks for the quick reply! Indeed, supporting offsets would be useful.
I'm a maintainer for the Python library
dltand my practical goal is to be able to useconnector-xas a dependency. This library uses the Rust cratearrowand brings significant performance improvements.However,
connector-xwas dealing with a bug withUTCtimezones which appear to be unsupported in the Rust crate.(i.e., it doesn't support UTC)
They switched to offset-based timezones, which solved their bug, but created downstream issues for some
dltusers.Given what you know, do you think that
connector-xadoptingtzdataformat instead of offsets or UTC could be a lasting solution? For instance,Africa/Bissauseems to match UTC or +00:00 (could be facing daylight saving time issues?). Alternatively, I could modifydltcode to any+00:00offsets into UTCMany thanks!
rok commentedon Jul 10, 2025
Please note
arrow-rshas a separate issue tracker, while here we now mostly track C++ implementation and it's wrappers. I am not intimately familiar with the rust implementation so perhaps you want to ask there too.As far as I know
UTC,Etc/UCT,Etc/GMT,Etc/GMT+X,Etc/GMT-Xare all valid timezones that are equivalent to+/-XX:00offsets. As long as you don't need+/-XX:30offsets (I don't know why this is a thing) and logic for mapping offset strings into offset timezones (e.g.-10:00=>Etc/GMT-10:00) can be put somewhere this should imo be a lasting solution. Probably it'd be better if we didn't use offsets at all, but that is probably not a realistic option.zilto commentedon Jul 10, 2025
Thank you so much! That was very helpful.
Feel free to close this issue as duplicate or keep it open :)
zilto commentedon Jul 17, 2025
Summary
TL;DR for people stumbling onto this issue:
pyarrow, but some specific features don't support offset-based time zones (e.g.,"+01:00").pyarrow._csv.CSVWriter(...).write()orpyarrow.TimeScalar(...).__repr__()pyarrow(Arrow C) because it doesn't default to offset-based timestamps. However, other arrow implementations (e.g., Arrow Rust) may default to using themIssue
For follow-up, I pinned down my issue to this problem:
Manual solution
zilto commentedon Dec 2, 2025
Solved by #12865