aniaan commented on a change in pull request #17048:
URL: https://github.com/apache/superset/pull/17048#discussion_r750361686
##########
File path: superset/db_engine_specs/elasticsearch.py
##########
@@ -59,9 +60,24 @@ def get_dbapi_exception_mapping(cls) ->
Dict[Type[Exception], Type[Exception]]:
}
@classmethod
- def convert_dttm(cls, target_type: str, dttm: datetime) -> Optional[str]:
+ def convert_dttm(
+ cls, target_type: str, dttm: datetime, db_extra: Optional[Dict[str,
Any]] = None
+ ) -> Optional[str]:
+
+ db_extra = db_extra if db_extra else {}
if target_type.upper() == utils.TemporalType.DATETIME:
+ es_version = db_extra.get("version")
+ # The elasticsearch CAST function does not take effect for the
time zone
+ # setting. In elasticsearch7.8 and above, we can use the
DATETIME_PARSE
+ # function to solve this problem.
+ if es_version and StrictVersion(es_version) >=
StrictVersion("7.8"):
+ datetime_formatted = dttm.isoformat(sep=" ",
timespec="seconds")
+ return (
+ f"""DATETIME_PARSE('{datetime_formatted}', 'yyyy-MM-dd
HH:mm:ss')"""
+ )
Review comment:
@villebro I have updated it, you can review it when you have time
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]