superset-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] mistercrunch closed pull request #4925: Support Apache Kylin in EngineSpec
Date Thu, 03 May 2018 15:42:45 GMT
mistercrunch closed pull request #4925: Support Apache Kylin in EngineSpec
URL: https://github.com/apache/incubator-superset/pull/4925
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/superset/db_engine_specs.py b/superset/db_engine_specs.py
index 49dd39cd6d..85922f6a6f 100644
--- a/superset/db_engine_specs.py
+++ b/superset/db_engine_specs.py
@@ -1307,6 +1307,32 @@ class DruidEngineSpec(BaseEngineSpec):
     inner_joins = False
 
 
+class KylinEngineSpec(BaseEngineSpec):
+    """Dialect for Apache Kylin"""
+
+    engine = 'kylin'
+
+    time_grains = (
+        Grain('Time Column', _('Time Column'), '{col}', None),
+        Grain('second', _('second'), 'SECOND({col})', 'PT1S'),
+        Grain('minute', _('minute'), 'MINUTE({col})', 'PT1M'),
+        Grain('hour', _('hour'), 'HOUR({col})', 'PT1H'),
+        Grain('month', _('month'), 'MONTH({col})', 'P1M'),
+        Grain('quarter', _('quarter'), 'QUARTER({col})', 'P0.25Y'),
+        Grain('year', _('year'), 'YEAR({col})', 'P1Y'),
+    )
+
+    @classmethod
+    def convert_dttm(cls, target_type, dttm):
+        tt = target_type.upper()
+        if tt == 'DATE':
+            return "CAST('{}' AS DATE)".format(dttm.isoformat()[:10])
+        if 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'))
+
+
 engines = {
     o.engine: o for o in globals().values()
     if inspect.isclass(o) and issubclass(o, BaseEngineSpec)}


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


Mime
View raw message