mirror of
https://github.com/apache/superset.git
synced 2026-04-20 08:34:37 +00:00
fix: Oracle fetch_query and datetime conversion (#9240)
This commit is contained in:
@@ -17,11 +17,10 @@
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
|
||||
from superset.db_engine_specs.base import LimitMethod
|
||||
from superset.db_engine_specs.postgres import PostgresBaseEngineSpec
|
||||
from superset.db_engine_specs.base import BaseEngineSpec, LimitMethod
|
||||
|
||||
|
||||
class OracleEngineSpec(PostgresBaseEngineSpec):
|
||||
class OracleEngineSpec(BaseEngineSpec):
|
||||
engine = "oracle"
|
||||
limit_method = LimitMethod.WRAP_SQL
|
||||
force_column_alias_quotes = True
|
||||
@@ -44,6 +43,16 @@ class OracleEngineSpec(PostgresBaseEngineSpec):
|
||||
tt = target_type.upper()
|
||||
if tt == "DATE":
|
||||
return f"TO_DATE('{dttm.date().isoformat()}', 'YYYY-MM-DD')"
|
||||
if tt == "DATETIME":
|
||||
return f"""TO_DATE('{dttm.isoformat(timespec="seconds")}', 'YYYY-MM-DD"T"HH24:MI:SS')""" # pylint: disable=line-too-long
|
||||
if tt == "TIMESTAMP":
|
||||
return f"""TO_TIMESTAMP('{dttm.isoformat(timespec="microseconds")}', 'YYYY-MM-DD"T"HH24:MI:SS.ff6')""" # pylint: disable=line-too-long
|
||||
return None
|
||||
|
||||
@classmethod
|
||||
def epoch_to_dttm(cls) -> str:
|
||||
return "TO_DATE('1970-01-01','YYYY-MM-DD')+(1/24/60/60)*{col}"
|
||||
|
||||
@classmethod
|
||||
def epoch_ms_to_dttm(cls) -> str:
|
||||
return "TO_DATE('1970-01-01','YYYY-MM-DD')+(1/24/60/60/1000)*{col}"
|
||||
|
||||
Reference in New Issue
Block a user