From 62959ca38ba31e5cc5a1d2b7b9e16bf981f97300 Mon Sep 17 00:00:00 2001 From: openmax Date: Wed, 5 Apr 2017 09:03:24 +0200 Subject: [PATCH] Db2 Grain Correct Data Format (#2545) * Db2 Grain Correct Data Format * Db2 Grain Correct Data Format. * Db2 Grain Correct Data Format + typo * Db2 Grain Correct Data Format +typo --- superset/db_engine_specs.py | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/superset/db_engine_specs.py b/superset/db_engine_specs.py index 40a824fae6d94..a8bf9ead5cd77 100644 --- a/superset/db_engine_specs.py +++ b/superset/db_engine_specs.py @@ -195,14 +195,35 @@ class Db2EngineSpec(BaseEngineSpec): engine = 'ibm_db_sa' time_grains = ( Grain('Time Column', _('Time Column'), '{col}'), - Grain('second', _('second'), 'SECOND({col})'), - Grain('minute', _('minute'), 'MINUTE({col})'), - Grain('hour', _('hour'), 'HOUR({col})'), - Grain('day', _('day'), 'DAY({col})'), - Grain('week', _('week'), 'WEEK({col})'), - Grain('month', _('month'), 'MONTH({col})'), - Grain('quarter', _('quarter'), 'QUARTER({col})'), - Grain('year', _('year'), 'YEAR({col})'), + Grain('second', _('second'), + 'CAST({col} as TIMESTAMP)' + ' - MICROSECOND({col}) MICROSECONDS'), + Grain('minute', _('minute'), + 'CAST({col} as TIMESTAMP)' + ' - SECOND({col}) SECONDS' + ' - MICROSECOND({col}) MICROSECONDS'), + Grain('hour', _('hour'), + 'CAST({col} as TIMESTAMP)' + ' - MINUTE({col}) MINUTES' + ' - SECOND({col}) SECONDS' + ' - MICROSECOND({col}) MICROSECONDS '), + Grain('day', _('day'), + 'CAST({col} as TIMESTAMP)' + ' - HOUR({col}) HOURS' + ' - MINUTE({col}) MINUTES' + ' - SECOND({col}) SECONDS' + ' - MICROSECOND({col}) MICROSECONDS '), + Grain('week', _('week'), + '{col} - (DAYOFWEEK({col})) DAYS'), + Grain('month', _('month'), + '{col} - (DAY({col})-1) DAYS'), + Grain('quarter', _('quarter'), + '{col} - (DAY({col})-1) DAYS' + ' - (MONTH({col})-1) MONTHS' + ' + ((QUARTER({col})-1) * 3) MONTHS'), + Grain('year', _('year'), + '{col} - (DAY({col})-1) DAYS' + ' - (MONTH({col})-1) MONTHS'), ) @classmethod