Skip to content

Commit

Permalink
add oracle time_grains (#1544)
Browse files Browse the repository at this point in the history
  • Loading branch information
gschrader authored and mistercrunch committed Nov 4, 2016
1 parent 1d7d546 commit 757e7de
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions caravel/db_engine_specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,24 @@ class RedshiftEngineSpec(PostgresEngineSpec):
class OracleEngineSpec(PostgresEngineSpec):
engine = 'oracle'

time_grains = (
Grain('Time Column', _('Time Column'), '{col}'),
Grain('minute', _('minute'),
"TRUNC(TO_DATE({col}), 'MI')"),
Grain('hour', _('hour'),
"TRUNC(TO_DATE({col}), 'HH')"),
Grain('day', _('day'),
"TRUNC(TO_DATE({col}), 'DDD')"),
Grain('week', _('week'),
"TRUNC(TO_DATE({col}), 'WW')"),
Grain('month', _('month'),
"TRUNC(TO_DATE({col}), 'MONTH')"),
Grain('quarter', _('quarter'),
"TRUNC(TO_DATE({col}), 'Q')"),
Grain('year', _('year'),
"TRUNC(TO_DATE({col}), 'YEAR')"),
)

@classmethod
def convert_dttm(cls, target_type, dttm):
return (
Expand Down

0 comments on commit 757e7de

Please sign in to comment.