Skip to content

Commit

Permalink
Add ibm_db_sa TimeStamp and Datatime Grain Spec. (#2500)
Browse files Browse the repository at this point in the history
* Add ibm_db_sa TimeStamp and Datatime Grain Spec.

* Add ibm_db_sa TimeStamp and Datatime Grain Spec. + Typo Err
  • Loading branch information
openmax authored and mistercrunch committed Mar 28, 2017
1 parent b35f6b0 commit f3cdb3b
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions superset/db_engine_specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,29 @@ def convert_dttm(cls, target_type, dttm):
return "'{}'".format(dttm.strftime('%Y-%m-%d %H:%M:%S'))


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})'),
)

@classmethod
def epoch_to_dttm(cls):
return "(TIMESTAMP('1970-01-01', '00:00:00') + {col} SECONDS)"

@classmethod
def convert_dttm(cls, target_type, dttm):
return "'{}'".format(dttm.strftime('%Y-%m-%d-%H.%M.%S'))


class SqliteEngineSpec(BaseEngineSpec):
engine = 'sqlite'
time_grains = (
Expand Down

0 comments on commit f3cdb3b

Please sign in to comment.