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:
Rui Zhao
2026-03-31 10:28:06 -07:00
committed by GitHub
parent 55aa36fef8
commit 53b1d1097c
2 changed files with 16 additions and 3 deletions

View File

@@ -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: (
__(

View File

@@ -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'",
),
],
)