mirror of
https://github.com/apache/superset.git
synced 2026-05-29 11:45:16 +00:00
fix(presto): Fix presto timestamp (#26467)
Co-authored-by: Claude Code <noreply@anthropic.com> Co-authored-by: Rui Zhao <zhaorui@dropbox.com> Co-authored-by: Joe Li <joe@preset.io>
This commit is contained in:
@@ -920,6 +920,19 @@ class PrestoEngineSpec(PrestoBaseEngineSpec):
|
||||
],
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def convert_dttm(
|
||||
cls, target_type: str, dttm: datetime, db_extra: dict[str, Any] | None = None
|
||||
) -> str | None:
|
||||
sqla_type = cls.get_sqla_column_type(target_type)
|
||||
|
||||
if isinstance(sqla_type, types.Date):
|
||||
return f"DATE '{dttm.date().isoformat()}'"
|
||||
if isinstance(sqla_type, types.TIMESTAMP):
|
||||
return f"""TIMESTAMP '{dttm.isoformat(timespec="milliseconds", sep=" ")}'"""
|
||||
|
||||
return None
|
||||
|
||||
custom_errors: dict[Pattern[str], tuple[str, SupersetErrorType, dict[str, Any]]] = {
|
||||
COLUMN_DOES_NOT_EXIST_REGEX: (
|
||||
__(
|
||||
|
||||
@@ -42,17 +42,17 @@ from tests.unit_tests.db_engine_specs.utils import (
|
||||
(
|
||||
"TIMESTAMP",
|
||||
datetime(2022, 1, 1, 1, 23, 45, 600000),
|
||||
"TIMESTAMP '2022-01-01 01:23:45.600000'",
|
||||
"TIMESTAMP '2022-01-01 01:23:45.600'",
|
||||
),
|
||||
(
|
||||
"TIMESTAMP WITH TIME ZONE",
|
||||
datetime(2022, 1, 1, 1, 23, 45, 600000),
|
||||
"TIMESTAMP '2022-01-01 01:23:45.600000'",
|
||||
"TIMESTAMP '2022-01-01 01:23:45.600'",
|
||||
),
|
||||
(
|
||||
"TIMESTAMP WITH TIME ZONE",
|
||||
datetime(2022, 1, 1, 1, 23, 45, 600000, tzinfo=pytz.UTC),
|
||||
"TIMESTAMP '2022-01-01 01:23:45.600000+00:00'",
|
||||
"TIMESTAMP '2022-01-01 01:23:45.600+00:00'",
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user