mirror of
https://github.com/apache/superset.git
synced 2026-04-20 00:24:38 +00:00
[sqllab] adding a sql preprocessor for Presto (#1670)
* [sqllab] adding a sql preprocessor for Presto * fixing tests
This commit is contained in:
committed by
GitHub
parent
b370ef0229
commit
cef4a8296a
@@ -63,6 +63,14 @@ class BaseEngineSpec(object):
|
||||
query object"""
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def sql_preprocessor(cls, sql):
|
||||
"""If the SQL needs to be altered prior to running it
|
||||
|
||||
For example Presto needs to double `%` characters
|
||||
"""
|
||||
return sql
|
||||
|
||||
|
||||
class PostgresEngineSpec(BaseEngineSpec):
|
||||
engine = 'postgresql'
|
||||
@@ -172,6 +180,10 @@ class PrestoEngineSpec(BaseEngineSpec):
|
||||
"date_add('day', 1, CAST({col} AS TIMESTAMP))))"),
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def sql_preprocessor(cls, sql):
|
||||
return sql.replace('%', '%%')
|
||||
|
||||
@classmethod
|
||||
def convert_dttm(cls, target_type, dttm):
|
||||
tt = target_type.upper()
|
||||
|
||||
Reference in New Issue
Block a user