villebro commented on a change in pull request #8464: [SIP-15] Fixing datetime 
conversion and SQL literal
URL: 
https://github.com/apache/incubator-superset/pull/8464#discussion_r340276849
 
 

 ##########
 File path: superset/db_engine_specs/drill.py
 ##########
 @@ -49,13 +50,13 @@ def epoch_ms_to_dttm(cls) -> str:
         return "TO_DATE({col})"
 
     @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 "CAST('{}' AS DATE)".format(dttm.isoformat()[:10])
+            return f"TO_DATE('{dttm.date().isoformat()}', 'yyyy-MM-dd')"
         elif tt == "TIMESTAMP":
-            return "CAST('{}' AS TIMESTAMP)".format(dttm.strftime("%Y-%m-%d 
%H:%M:%S"))
-        return "'{}'".format(dttm.strftime("%Y-%m-%d %H:%M:%S"))
+            return f"""TO_TIMESTAMP('{dttm.isoformat(sep=" ", 
timespec="seconds")}', 'yyyy-MM-dd HH:mm:ss')"""  # pylint: 
disable=line-too-long
+        return None
 
 Review comment:
   @cgivre can you check if these are valid and if there's anything missing? A 
quick googling didn't turn up any `DATETIME` type for Drill, just `DATE`, 
`TIME` and `TIMESTAMP`.

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