You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2022/07/02 21:33:00 UTC
[jira] [Work logged] (AVRO-3476) Python implementation does not support local-timestamp-micros and local-timestamp-millis
[ https://issues.apache.org/jira/browse/AVRO-3476?focusedWorklogId=787356&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-787356 ]
ASF GitHub Bot logged work on AVRO-3476:
----------------------------------------
Author: ASF GitHub Bot
Created on: 02/Jul/22 21:32
Start Date: 02/Jul/22 21:32
Worklog Time Spent: 10m
Work Description: kojiromike commented on code in PR #1634:
URL: https://github.com/apache/avro/pull/1634#discussion_r912402445
##########
lang/py/avro/io.py:
##########
@@ -362,25 +362,52 @@ def read_time_micros_from_long(self) -> datetime.time:
microseconds = self.read_long()
return self._build_time_object(microseconds, 1)
- def read_timestamp_millis_from_long(self) -> datetime.datetime:
+ def _read_timestamp_millis_from_long(self, tz:bool) -> datetime.datetime:
"""
long is decoded as python datetime object which represents
the number of milliseconds from the unix epoch, 1 January 1970.
"""
timestamp_millis = self.read_long()
timedelta = datetime.timedelta(microseconds=timestamp_millis * 1000)
- unix_epoch_datetime = datetime.datetime(1970, 1, 1, 0, 0, 0, 0, tzinfo=avro.timezones.utc)
+ unix_epoch_datetime = datetime.datetime(1970, 1, 1, 0, 0, 0, 0, tzinfo=avro.timezones.utc if tz else None)
return unix_epoch_datetime + timedelta
- def read_timestamp_micros_from_long(self) -> datetime.datetime:
+ def _read_timestamp_micros_from_long(self,tz:bool) -> datetime.datetime:
"""
long is decoded as python datetime object which represents
the number of microseconds from the unix epoch, 1 January 1970.
"""
timestamp_micros = self.read_long()
timedelta = datetime.timedelta(microseconds=timestamp_micros)
- unix_epoch_datetime = datetime.datetime(1970, 1, 1, 0, 0, 0, 0, tzinfo=avro.timezones.utc)
+ unix_epoch_datetime = datetime.datetime(1970, 1, 1, 0, 0, 0, 0, tzinfo=avro.timezones.utc if tz else None)
return unix_epoch_datetime + timedelta
+ def read_local_timestamp_micros_from_long(self) -> datetime.datetime:
Review Comment:
Are you sure about this? I am not great at reading Java, but I understand that a `LocalDateTime` is essentially a DateTime without a timezone, which is what I'm doing here: setting `tz=None` if the type is local.
Issue Time Tracking
-------------------
Worklog Id: (was: 787356)
Time Spent: 1h (was: 50m)
> Python implementation does not support local-timestamp-micros and local-timestamp-millis
> ----------------------------------------------------------------------------------------
>
> Key: AVRO-3476
> URL: https://issues.apache.org/jira/browse/AVRO-3476
> Project: Apache Avro
> Issue Type: Bug
> Components: python
> Affects Versions: 1.11.0
> Reporter: Eric
> Priority: Major
> Labels: pull-request-available
> Time Spent: 1h
> Remaining Estimate: 0h
>
> Even though [they are present in the spec|https://avro.apache.org/docs/1.11.0/spec.html#Local+timestamp+(millisecond+precision)], the Python implementation does not support logical types local-timestamp-micros and local-timestamp-millis.
> When trying to use them, you get the following:
> {code:python}
> .../lib/python3.8/site-packages/avro/schema.py:1048: IgnoredLogicalType: Unknown local-timestamp-micros, using long.
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)