[hotfix] fix support for presto DATE and TIMESTAMP type

This commit is contained in:
Maxime Beauchemin 2016-11-11 00:39:20 +00:00
parent 7325a4fb4b
commit d6bc354ff3
1 changed files with 5 additions and 2 deletions

View File

@ -174,8 +174,11 @@ class PrestoEngineSpec(BaseEngineSpec):
@classmethod
def convert_dttm(cls, target_type, dttm):
if target_type.upper() in ('DATE', 'DATETIME'):
return "from_iso8601_date('{}')".format(dttm.isoformat())
tt = target_type.upper()
if tt == 'DATE':
return "from_iso8601_date('{}')".format(dttm.isoformat()[:10])
if tt == 'TIMESTAMP':
return "from_iso8601_timestamp('{}')".format(dttm.isoformat())
return "'{}'".format(dttm.strftime('%Y-%m-%d %H:%M:%S'))
@classmethod