You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2019/11/16 16:08:02 UTC

[GitHub] [incubator-superset] mistercrunch commented on a change in pull request #8554: Fix hana time filter

mistercrunch commented on a change in pull request #8554: Fix hana time filter
URL: https://github.com/apache/incubator-superset/pull/8554#discussion_r347097147
 
 

 ##########
 File path: superset/db_engine_specs/hana.py
 ##########
 @@ -42,9 +42,24 @@ class HanaEngineSpec(PostgresBaseEngineSpec):
 
     @classmethod
     def convert_dttm(cls, target_type: str, dttm: datetime) -> Optional[str]:
+        """
+        Tested: hana time returns DATETIME and STRING
+        HANA:
+        :return dttm->DATETIME
+        HANA->DATE:f"TO_DATE('{dttm.date().isoformat()}', 'YYYY-MM-DD')"
+
+        :return dttm->DATETIME
+        HANA->TIMESTAMP:
+        f"TO_TIMESTAMP('{dttm.isoformat(timespec="microseconds")}',
+        'YYYY-MM-DD"T"HH24:MI:SS.ff6')"
+
+        :return dttm->STRING
+        HANA->NVARCHAR TYPE:f"TO_CHAR('{dttm.date().isoformat()}', 'YYYYMMDD')"
+        """
         tt = target_type.upper()
-        if tt == "DATE":
-            return f"TO_DATE('{dttm.date().isoformat()}', 'YYYY-MM-DD')"
-        if tt == "TIMESTAMP":
-            return f"""TO_TIMESTAMP('{dttm.isoformat(timespec="microseconds")}', 'YYYY-MM-DD"T"HH24:MI:SS.ff6')"""  # pylint: disable=line-too-long
+        if tt == "DATETIME":
 
 Review comment:
   This doc lists `DATE, TIME, SECONDDATE, TIMESTAMP` as the date-related types: https://help.sap.com/viewer/4fe29514fd584807ac9f2a04f6754767/2.0.03/en-US/20a1569875191014b507cf392724b7eb.html
   
   I'm not sure how the dialect/dbapi driver works, maybe the types get translated somewhere.
   
   It seems like there should be a catchall `else:` at the end, even if it's raising a `ValueError` or `NotImplementedError` to say something like "target data type {type} isn't handled by the DBEngineSpec for SAP Hana" or something like that...

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org