You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2020/03/16 09:44:24 UTC

[GitHub] [airflow] ashb commented on a change in pull request #6354: [AIRFLOW-5664] Store timestamps with microseconds precision in GCSToPSQL

ashb commented on a change in pull request #6354: [AIRFLOW-5664] Store timestamps with microseconds precision in GCSToPSQL
URL: https://github.com/apache/airflow/pull/6354#discussion_r392891388
 
 

 ##########
 File path: airflow/providers/google/cloud/operators/postgres_to_gcs.py
 ##########
 @@ -88,7 +90,7 @@ def convert_type(self, value, schema_type):
         Decimals are converted to floats. Times are converted to seconds.
         """
         if isinstance(value, (datetime.datetime, datetime.date)):
-            return time.mktime(value.timetuple())
+            return pendulum.parse(value.isoformat()).float_timestamp
 
 Review comment:
   Holy in-efficiency batman!
   
   We're doing from a datetime, to a string (a bit slow) parsing it _back_ to a datetime-like object (_VERY_ slow) to then call an attribute on it.
   
   This should be
   
   ```
                return value.timestamp()
   ```
   
   Also the comment should be clarified. "Times are converted to fractional-seconds"
   
   

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services