diff --git a/caravel/models.py b/caravel/models.py index bbe723ce9b51..91338b1d216a 100644 --- a/caravel/models.py +++ b/caravel/models.py @@ -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):