Skip to content

Commit

Permalink
Better type detection for inference of column matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Apr 15, 2016
1 parent 4b48e9f commit ebe4ee2
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions caravel/models.py
Expand Up @@ -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 '')

Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit ebe4ee2

Please sign in to comment.