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/15 18:06:46 UTC

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

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

 ##########
 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:
   Can you explain this in more detail? I'm having a hard time following how this works, as I'm unfamiliar with the internals of SAP/Hana.

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