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/05/27 19:47:22 UTC

[GitHub] [incubator-superset] villebro commented on a change in pull request #6610: [WIP] Add support for Apache Drill

villebro commented on a change in pull request #6610: [WIP] Add support for Apache Drill
URL: https://github.com/apache/incubator-superset/pull/6610#discussion_r287871414
 
 

 ##########
 File path: superset/db_engine_specs.py
 ##########
 @@ -724,6 +724,46 @@ def get_table_names(cls, inspector, schema):
         return sorted(inspector.get_table_names())
 
 
+class DrillEngineSpec(BaseEngineSpec):
+    """Engine spec for Apache Drill"""
+    engine = 'drill'
+
+    time_grain_functions = {
+        None: '{col}',
+        'PT1S': "nearestDate({col}, 'SECOND')",
+        'PT1M': "nearestDate({col}, 'MINUTE')",
+        'PT15M': "nearestDate({col}, 'QUARTER_HOUR')",
+        'PT0.5H': "nearestDate({col}, 'HALF_HOUR')",
+        'PT1H': "nearestDate({col}, 'HOUR')",
+        'P1D': 'TO_DATE({col})',
+        'P1W': "nearestDate({col}, 'WEEK_SUNDAY')",
+        'P1M': "nearestDate({col}, 'MONTH')",
+        'P0.25Y': "nearestDate({col}, 'QUARTER')",
+        'P1Y': "nearestDate({col}, 'YEAR')",
+    }
+
+    # Returns a function to convert a Unix timestamp in milliseconds to a date
+    @classmethod
+    def epoch_to_dttm(cls):
+        return 'TO_DATE({col})'
 
 Review comment:
   `epoch_to_dttm` should convert epoch in seconds to dttm, not milliseconds (the method `epoch_ms_to_dttm` is reserved for that). I'm thinking something along the following lines could be the correct solution?
   ```python
       @classmethod
       def epoch_to_dttm(cls):
           return cls.epoch_ms_to_dttm().replace('{col}', '({col}*1000)')
   
       @classmethod
       def epoch_ms_to_dttm(cls):
           return 'TO_DATE({col})'
   ```

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