mirror of
https://github.com/apache/superset.git
synced 2026-04-19 16:14:52 +00:00
chore(db_engine_specs): clean up column spec logic and add tests (#22871)
This commit is contained in:
@@ -18,11 +18,11 @@ from datetime import datetime
|
||||
from typing import Any, Dict, Optional
|
||||
from urllib import parse
|
||||
|
||||
from sqlalchemy import types
|
||||
from sqlalchemy.engine.url import URL
|
||||
|
||||
from superset.db_engine_specs.base import BaseEngineSpec
|
||||
from superset.db_engine_specs.exceptions import SupersetDBAPIProgrammingError
|
||||
from superset.utils import core as utils
|
||||
|
||||
|
||||
class DrillEngineSpec(BaseEngineSpec):
|
||||
@@ -59,10 +59,11 @@ class DrillEngineSpec(BaseEngineSpec):
|
||||
def convert_dttm(
|
||||
cls, target_type: str, dttm: datetime, db_extra: Optional[Dict[str, Any]] = None
|
||||
) -> Optional[str]:
|
||||
tt = target_type.upper()
|
||||
if tt == utils.TemporalType.DATE:
|
||||
sqla_type = cls.get_sqla_column_type(target_type)
|
||||
|
||||
if isinstance(sqla_type, types.Date):
|
||||
return f"TO_DATE('{dttm.date().isoformat()}', 'yyyy-MM-dd')"
|
||||
if tt == utils.TemporalType.TIMESTAMP:
|
||||
if isinstance(sqla_type, types.TIMESTAMP):
|
||||
datetime_formatted = dttm.isoformat(sep=" ", timespec="seconds")
|
||||
return f"""TO_TIMESTAMP('{datetime_formatted}', 'yyyy-MM-dd HH:mm:ss')"""
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user