Fokko commented on code in PR #6197:
URL: https://github.com/apache/iceberg/pull/6197#discussion_r1024484631


##########
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:
   Ah, wasn't aware of that! Thanks!



-- 
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: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to