john-bodley commented on a change in pull request #8464: [sql] Fixing datetime
SQL literal
URL:
https://github.com/apache/incubator-superset/pull/8464#discussion_r339848196
##########
File path: superset/db_engine_specs/athena.py
##########
@@ -39,13 +40,13 @@ class AthenaEngineSpec(BaseEngineSpec):
}
@classmethod
- def convert_dttm(cls, target_type: str, dttm: datetime) -> str:
+ def convert_dttm(cls, target_type: str, dttm: datetime) -> Optional[str]:
tt = target_type.upper()
if tt == "DATE":
- return "from_iso8601_date('{}')".format(dttm.isoformat()[:10])
+ return f"""from_iso8601_date('{dttm.strftime("%Y-%m-%d")}')"""
if tt == "TIMESTAMP":
- return "from_iso8601_timestamp('{}')".format(dttm.isoformat())
- return "CAST ('{}' AS TIMESTAMP)".format(dttm.strftime("%Y-%m-%d
%H:%M:%S"))
Review comment:
We shouldn't be casting other types to `TIMESTAMP`. The reason for this
function is to ensure that the LHS and RHS for the time filter comparison are
equivalent types.
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]