mirror of
https://github.com/apache/superset.git
synced 2026-04-19 16:14:52 +00:00
feat: Add new timegrains and convert_dttm to Druid engine spec (#10160)
* feat: Add new timegrains and convert_dttm to Druid engine spec * Add TemporalType enum and fix test case * Remove DATETIME for athena (original spec)
This commit is contained in:
@@ -18,6 +18,7 @@ from datetime import datetime
|
||||
from typing import Optional
|
||||
|
||||
from superset.db_engine_specs.base import BaseEngineSpec, LimitMethod
|
||||
from superset.utils import core as utils
|
||||
|
||||
|
||||
class OracleEngineSpec(BaseEngineSpec):
|
||||
@@ -41,11 +42,11 @@ class OracleEngineSpec(BaseEngineSpec):
|
||||
@classmethod
|
||||
def convert_dttm(cls, target_type: str, dttm: datetime) -> Optional[str]:
|
||||
tt = target_type.upper()
|
||||
if tt == "DATE":
|
||||
if tt == utils.TemporalType.DATE:
|
||||
return f"TO_DATE('{dttm.date().isoformat()}', 'YYYY-MM-DD')"
|
||||
if tt == "DATETIME":
|
||||
if tt == utils.TemporalType.DATETIME:
|
||||
return f"""TO_DATE('{dttm.isoformat(timespec="seconds")}', 'YYYY-MM-DD"T"HH24:MI:SS')""" # pylint: disable=line-too-long
|
||||
if tt == "TIMESTAMP":
|
||||
if tt == utils.TemporalType.TIMESTAMP:
|
||||
return f"""TO_TIMESTAMP('{dttm.isoformat(timespec="microseconds")}', 'YYYY-MM-DD"T"HH24:MI:SS.ff6')""" # pylint: disable=line-too-long
|
||||
return None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user