Skip to content

Commit

Permalink
[hive] fix date casting in explore view (#3394)
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch authored Aug 30, 2017
1 parent 1fd08a5 commit 497a6f1
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions superset/db_engine_specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,16 @@ def fetch_result_sets(cls, db, datasource_type, force=False):
return BaseEngineSpec.fetch_result_sets(
db, datasource_type, force=force)

@classmethod
def convert_dttm(cls, target_type, dttm):
tt = target_type.upper()
if tt == 'DATE':
return "CAST('{}' AS DATE)".format(dttm.isoformat()[:10])
elif tt == 'TIMESTAMP':
return "CAST('{}' AS TIMESTAMP)".format(
dttm.strftime('%Y-%m-%d %H:%M:%S'))
return "'{}'".format(dttm.strftime('%Y-%m-%d %H:%M:%S'))

@classmethod
def adjust_database_uri(cls, uri, selected_schema=None):
if selected_schema:
Expand Down

0 comments on commit 497a6f1

Please sign in to comment.