Skip to content

Commit

Permalink
add postgres grains
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewhn committed Apr 5, 2016
1 parent c349b0a commit db076f7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions caravel/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,14 @@ def grains(self):
Grain('week', 'DATE_SUB({col}, INTERVAL DAYOFWEEK({col}) - 1 DAY)'),
Grain('month', 'DATE_SUB({col}, INTERVAL DAYOFMONTH({col}) - 1 DAY)'),
),
'postgresql': (
Grain("Time Column", "{col}"),
Grain("hour", "DATE_TRUNC('hour', {col})"),
Grain("day", "DATE_TRUNC('day', {col})"),
Grain("week", "DATE_TRUNC('week', {col})"),
Grain("month", "DATE_TRUNC('month', {col})"),
Grain("year", "DATE_TRUNC('year', {col})"),
),
}
for db_type, grains in db_time_grains.items():
if self.sqlalchemy_uri.startswith(db_type):
Expand Down

0 comments on commit db076f7

Please sign in to comment.