rdblue commented on code in PR #6197:
URL: https://github.com/apache/iceberg/pull/6197#discussion_r1024213544
##########
python/pyiceberg/utils/datetime.py:
##########
@@ -81,13 +81,19 @@ def timestamp_to_micros(timestamp_str: str) -> int:
"""Converts an ISO-9601 formatted timestamp without zone to microseconds
from 1970-01-01T00:00:00.000000"""
if ISO_TIMESTAMP.fullmatch(timestamp_str):
return datetime_to_micros(datetime.fromisoformat(timestamp_str))
+ if ISO_TIMESTAMPTZ.fullmatch(timestamp_str):
+ # When we can match a timestamp without a zone, we can give a more
specific error
+ raise ValueError(f"Timezone provided, but not expected:
{timestamp_str}")
raise ValueError(f"Invalid timestamp without zone: {timestamp_str} (must
be ISO-8601)")
def timestamptz_to_micros(timestamptz_str: str) -> int:
"""Converts an ISO-8601 formatted timestamp with zone to microseconds from
1970-01-01T00:00:00.000000+00:00"""
if ISO_TIMESTAMPTZ.fullmatch(timestamptz_str):
return datetime_to_micros(datetime.fromisoformat(timestamptz_str))
+ if ISO_TIMESTAMP.fullmatch(timestamptz_str):
+ # When we can match a timestamp without a zone, we can give a more
specific error
+ raise ValueError(f"Missing timezone: {timestamptz_str} (must be
ISO-8601)")
Review Comment:
This should be more specific that the problem is that the string is missing
a "zone offset". We don't accept time zone names.
##########
python/pyiceberg/utils/datetime.py:
##########
@@ -81,13 +81,19 @@ def timestamp_to_micros(timestamp_str: str) -> int:
"""Converts an ISO-9601 formatted timestamp without zone to microseconds
from 1970-01-01T00:00:00.000000"""
if ISO_TIMESTAMP.fullmatch(timestamp_str):
return datetime_to_micros(datetime.fromisoformat(timestamp_str))
+ if ISO_TIMESTAMPTZ.fullmatch(timestamp_str):
+ # When we can match a timestamp without a zone, we can give a more
specific error
+ raise ValueError(f"Timezone provided, but not expected:
{timestamp_str}")
Review Comment:
Zone offset here as well.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]