aniaan commented on a change in pull request #17048:
URL: https://github.com/apache/superset/pull/17048#discussion_r726175374



##########
File path: superset/db_engine_specs/elasticsearch.py
##########
@@ -59,10 +60,20 @@ def get_dbapi_exception_mapping(cls) -> 
Dict[Type[Exception], Type[Exception]]:
         }
 
     @classmethod
-    def convert_dttm(cls, target_type: str, dttm: datetime) -> Optional[str]:
-        if target_type.upper() == utils.TemporalType.DATETIME:
-            return f"""CAST('{dttm.isoformat(timespec="seconds")}' AS 
DATETIME)"""
-        return None
+    def convert_dttm(
+        cls, target_type: str, dttm: datetime, **kwargs: Any
+    ) -> Optional[str]:
+
+        if target_type.upper() != utils.TemporalType.DATETIME:
+            return None
+
+        es_version = kwargs.get("version")
+
+        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:
       It was first written according to the way of not short-circuiting, so 
there will be nested if. If the f-string is written in one line, then the 
length of this line will be too long, so the expression is extracted. This way 
of writing refers to drill .py#convert_dttm method




-- 
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]

Reply via email to