From a11095494f3fb73fe718c29634767363a25324c8 Mon Sep 17 00:00:00 2001 From: CyrilLeMat Date: Thu, 28 Sep 2017 17:55:51 +0200 Subject: [PATCH] add time granularity to redshift --- superset/db_engine_specs.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/superset/db_engine_specs.py b/superset/db_engine_specs.py index 71c6ab20d9b6f..674e9f3b707d6 100644 --- a/superset/db_engine_specs.py +++ b/superset/db_engine_specs.py @@ -866,6 +866,18 @@ def convert_dttm(cls, target_type, dttm): class RedshiftEngineSpec(PostgresEngineSpec): engine = 'redshift' + + time_grains = ( + Grain("Time Column", _('Time Column'), "{col}"), + Grain("second", _('second'), "DATE_TRUNC('second', {col})"), + Grain("minute", _('minute'), "DATE_TRUNC('minute', {col})"), + Grain("hour", _('hour'), "DATE_TRUNC('hour', {col})"), + Grain("day", _('day'), "DATE_TRUNC('day', {col})"), + Grain("week", _('week'), "DATE_TRUNC('week', {col})"), + Grain("month", _('month'), "DATE_TRUNC('month', {col})"), + Grain("quarter", _('quarter'), "DATE_TRUNC('quarter', {col})"), + Grain("year", _('year'), "DATE_TRUNC('year', {col})"), + ) class OracleEngineSpec(PostgresEngineSpec):