mirror of https://github.com/apache/superset.git
Support Apache Kylin in EngineSpec (#4925)
* Support Apache Kylin in EngineSpec * Fix flake8
This commit is contained in:
parent
e213ccd438
commit
5d6e59aa8a
|
@ -1314,6 +1314,32 @@ class DruidEngineSpec(BaseEngineSpec):
|
||||||
inner_joins = False
|
inner_joins = False
|
||||||
|
|
||||||
|
|
||||||
|
class KylinEngineSpec(BaseEngineSpec):
|
||||||
|
"""Dialect for Apache Kylin"""
|
||||||
|
|
||||||
|
engine = 'kylin'
|
||||||
|
|
||||||
|
time_grains = (
|
||||||
|
Grain('Time Column', _('Time Column'), '{col}', None),
|
||||||
|
Grain('second', _('second'), 'SECOND({col})', 'PT1S'),
|
||||||
|
Grain('minute', _('minute'), 'MINUTE({col})', 'PT1M'),
|
||||||
|
Grain('hour', _('hour'), 'HOUR({col})', 'PT1H'),
|
||||||
|
Grain('month', _('month'), 'MONTH({col})', 'P1M'),
|
||||||
|
Grain('quarter', _('quarter'), 'QUARTER({col})', 'P0.25Y'),
|
||||||
|
Grain('year', _('year'), 'YEAR({col})', 'P1Y'),
|
||||||
|
)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def convert_dttm(cls, target_type, dttm):
|
||||||
|
tt = target_type.upper()
|
||||||
|
if tt == 'DATE':
|
||||||
|
return "CAST('{}' AS DATE)".format(dttm.isoformat()[:10])
|
||||||
|
if 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'))
|
||||||
|
|
||||||
|
|
||||||
engines = {
|
engines = {
|
||||||
o.engine: o for o in globals().values()
|
o.engine: o for o in globals().values()
|
||||||
if inspect.isclass(o) and issubclass(o, BaseEngineSpec)}
|
if inspect.isclass(o) and issubclass(o, BaseEngineSpec)}
|
||||||
|
|
Loading…
Reference in New Issue