From 1a6757f10a6e68377776cd498a5bb3cba66b7b09 Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Thu, 14 Apr 2016 21:24:04 -0700 Subject: [PATCH] Better type detection for inference of column matrix (#353) --- caravel/models.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/caravel/models.py b/caravel/models.py index 29d3ca35a966d..0fce58e6e0b7b 100644 --- a/caravel/models.py +++ b/caravel/models.py @@ -69,7 +69,7 @@ def changed_by_fk(cls): # noqa def created_by_(self): # noqa return '{}'.format(self.created_by or '') - @property # noqa + @property # noqa def changed_by_(self): return '{}'.format(self.changed_by or '') @@ -687,14 +687,16 @@ def fetch_metadata(self): if not dbcol: dbcol = TableColumn(column_name=col.name) num_types = ('DOUBLE', 'FLOAT', 'INT', 'BIGINT', 'LONG') + date_types = ('DATE', 'TIME') + str_types = ('VARCHAR', 'STRING') datatype = str(datatype).upper() - if ( - str(datatype).startswith('VARCHAR') or - str(datatype).startswith('STRING')): + if any([t in datatype for t in str_types]): dbcol.groupby = True dbcol.filterable = True elif any([t in datatype for t in num_types]): dbcol.sum = True + elif any([t in datatype for t in date_types]): + dbcol.is_dttm = True db.session.merge(self) self.columns.append(dbcol)