This is an automated email from the ASF dual-hosted git repository. maximebeauchemin pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
The following commit(s) were added to refs/heads/master by this push: new 166c576 Add basic Impala engine spec (#3225) 166c576 is described below commit 166c576c94ef78e15af0e8a4f90c10e41d334de6 Author: Maxime Beauchemin <maximebeauche...@gmail.com> AuthorDate: Fri Aug 4 09:10:32 2017 -0700 Add basic Impala engine spec (#3225) From: https://www.cloudera.com/documentation/enterprise/5-8-x/topics/impala_datetime_functions.html --- superset/db_engine_specs.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/superset/db_engine_specs.py b/superset/db_engine_specs.py index f159c7c..0b804b3 100644 --- a/superset/db_engine_specs.py +++ b/superset/db_engine_specs.py @@ -978,6 +978,31 @@ class BQEngineSpec(BaseEngineSpec): return "'{}'".format(dttm.strftime('%Y-%m-%d %H:%M:%S')) +class ImpalaEngineSpec(BaseEngineSpec): + """Engine spec for Cloudera's Impala""" + + engine = 'impala' + + time_grains = ( + Grain("Time Column", _('Time Column'), "{col}"), + Grain("minute", _('minute'), "TRUNC({col}, 'MI')"), + Grain("hour", _('hour'), "TRUNC({col}, 'HH')"), + Grain("day", _('day'), "TRUNC({col}, 'DD')"), + Grain("week", _('week'), "TRUNC({col}, 'WW')"), + Grain("month", _('month'), "TRUNC({col}, 'MONTH')"), + Grain("quarter", _('quarter'), "TRUNC({col}, 'Q')"), + Grain("year", _('year'), "TRUNC({col}, 'YYYY')"), + ) + + @classmethod + def convert_dttm(cls, target_type, dttm): + tt = target_type.upper() + if tt == 'DATE': + return "'{}'".format(dttm.strftime('%Y-%m-%d')) + else: + 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)} -- To stop receiving notification emails like this one, please contact ['"comm...@superset.apache.org" <comm...@superset.apache.org>'].