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_r339846744
 
 

 ##########
 File path: superset/db_engine_specs/elasticsearch.py
 ##########
 @@ -41,7 +41,7 @@ class ElasticSearchEngineSpec(BaseEngineSpec):
     type_code_map: Dict[int, str] = {}  # loaded from get_datatype only if 
needed
 
     @classmethod
-    def convert_dttm(cls, target_type: str, dttm: datetime) -> str:
-        if target_type.upper() in ("DATETIME", "DATE"):
-            return f"'{dttm.isoformat()}'"
-        return f"'{dttm.strftime('%Y-%m-%d %H:%M:%S')}'"
+    def convert_dttm(cls, target_type: str, dttm: datetime) -> Optional[str]:
+        if target_type.upper() in ("DATE", "DATETIME"):
+            return f"CAST('{dttm.isoformat()}' AS TIMESTAMP)"
 
 Review comment:
   @dpgaspar I know you recently added this and I was hoping you could validate 
the logic. 

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

Reply via email to