Skip to content

Commit

Permalink
Db2 Grain Correct Data Format (#2545)
Browse files Browse the repository at this point in the history
* Db2 Grain Correct Data Format

* Db2 Grain Correct Data Format.

* Db2 Grain Correct Data Format + typo

* Db2 Grain Correct Data Format +typo
  • Loading branch information
openmax authored and mistercrunch committed Apr 5, 2017
1 parent fe68bc3 commit 62959ca
Showing 1 changed file with 29 additions and 8 deletions.
37 changes: 29 additions & 8 deletions superset/db_engine_specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 62959ca

Please sign in to comment.