You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/09/29 17:47:48 UTC
[GitHub] [superset] eric-briscoe commented on a diff in pull request #21652: fix: `year 54714 is out of range` issue with async queries
eric-briscoe commented on code in PR #21652:
URL: https://github.com/apache/superset/pull/21652#discussion_r983857045
##########
superset/sql_lab.py:
##########
@@ -233,7 +233,7 @@ def execute_sql_statement( # pylint: disable=too-many-arguments,too-many-statem
)
if apply_ctas:
if not query.tmp_table_name:
- start_dttm = datetime.fromtimestamp(query.start_time)
+ start_dttm = datetime.fromtimestamp(query.start_time / 1000)
Review Comment:
is query.start_time a value in milliseconds? That appears to tbe the case as datetime.fromtimestamp expects values in seconds since epoch and you are dividing by 1000 here. To make this code more clear for future devs I would recommend creating a variable MILLISECONDS_PER_SECOND = 1000
Then change
start_dttm = datetime.fromtimestamp(query.start_time / MILLISECONDS_PER_SECOND)
This adds clarity to what the division is accomplishing and avoid the "[magic number](https://en.wikipedia.org/wiki/Magic_number_(programming))" scenario where future dev will ask what does 1000 represent?
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org