Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add postgres grains #262

Merged
merged 1 commit into from
Apr 5, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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