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/14 07:52:41 UTC

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

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

 ##########
 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":
+            return f"""TO_TIMESTAMP('{dttm.isoformat(timespec="microseconds")}', \
+             'YYYY-MM-DD"T"HH24:MI:SS.ff6')"""  # pylint: disable=line-too-long
+        if tt == "STRING":
 
 Review comment:
   We don’t want to handle the generic string conversion here as it depends on the string format.
   
   Could you update the unit tests as well (which may serve as a better mechanism for documenting this 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:
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