hequn8128 commented on a change in pull request #11439: [FLINK-16650][python] 
Support LocalZonedTimestampType for Python UDF in blink planner
URL: https://github.com/apache/flink/pull/11439#discussion_r394771945
 
 

 ##########
 File path: flink-python/pyflink/table/types.py
 ##########
 @@ -490,12 +492,20 @@ def need_conversion(self):
 
     def to_sql_type(self, dt):
         if dt is not None:
+            if dt.tzinfo is not None:
+                offset = dt.utcoffset()
+                offset = offset if offset else datetime.timedelta()
+                offset_microseconds =\
+                    (offset.days * 86400 + offset.seconds) * 10 ** 6 + 
offset.microseconds
+            else:
+                offset_microseconds = self.EPOCH_ORDINAL
             seconds = (calendar.timegm(dt.utctimetuple()) if dt.tzinfo
                        else time.mktime(dt.timetuple()))
-            return int(seconds) * 10 ** 6 + dt.microsecond
+            return int(seconds) * 10 ** 6 + dt.microsecond + 
offset_microseconds
 
 Review comment:
   Take local timezone into consideration? For example, time 0h in Japen should 
return -1h in China.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to