kz930 commented on code in PR #8704:
URL: https://github.com/apache/texera/pull/8704#discussion_r4382885941
##########
amber/src/main/python/core/models/schema/attribute_type.py:
##########
@@ -98,21 +102,57 @@ def _parse_bool(v):
def _parse_timestamp(v):
+ # A TIMESTAMP reaches a worker as a wall clock with no zone, so a value
+ # parsed here holds none either and compares with a row's. An offset is
+ # moved to the machine's zone first, as the engine's DateParserUtils does.
if _is_empty_value(v):
- return datetime.datetime(1970, 1, 1, tzinfo=datetime.timezone.utc)
+ return datetime.datetime(1970, 1, 1)
normalized_value = str(v)
if normalized_value.endswith("Z"):
normalized_value = normalized_value[:-1] + "+00:00"
parsed_value = datetime.datetime.fromisoformat(normalized_value)
- if (
- parsed_value.tzinfo is None
- or parsed_value.tzinfo.utcoffset(parsed_value) is None
- ):
- return parsed_value.replace(tzinfo=datetime.timezone.utc)
+ if parsed_value.utcoffset() is not None:
+ return _local_wall_clock(parsed_value)
return parsed_value
+def _local_wall_clock(moment):
+ # The wall clock the machine's zone shows at an instant that states its
+ # offset. Windows' localtime refuses an instant before 1970, so the zone is
+ # asked by name where it has one, and otherwise such an instant takes the
+ # machine's standard offset.
+ zone = _named_local_zone()
+ if zone is not None:
+ return moment.astimezone(zone).replace(tzinfo=None)
Review Comment:
Fixed in 5b7746a41: before 1900 the parse now takes the zone's standard
offset, the same rule as `_texera_local_wall_clock`, and your two cases are
tests (06:00 and 17:30, matching JDK 17).
--
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]