-
Notifications
You must be signed in to change notification settings - Fork 14.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BUG) Superset get wrong value of TIMESTAMP WITH TIME ZONE type field on Trino client #28685
Comments
Hey @okayhooni! I'm here to help you with any bugs, questions, or contributions you have for the project. Let's squash those bugs together! 🐞 The issue you're encountering with
To fix the issue, you can manually reapply the changes from PR 19263 to your local class PrestoBaseEngineSpec(BaseEngineSpec, metaclass=ABCMeta):
"""
A base class that share common functions between Presto and Trino
"""
supports_dynamic_schema = True
supports_catalog = supports_dynamic_catalog = True
column_type_mappings = (
# ... other mappings ...
(
re.compile(r"^timestamp with time zone.*", re.IGNORECASE),
types.TIMESTAMP(timezone=True),
GenericDataType.TEMPORAL,
),
# ... other mappings ...
)
@classmethod
def convert_dttm(
cls, target_type: str, dttm: datetime, db_extra: dict[str, Any] | None = None
) -> str | None:
"""
Convert a Python `datetime` object to a SQL expression.
:param target_type: The target type of expression
:param dttm: The datetime object
:param db_extra: The database extra object
:return: The SQL expression
Superset only defines time zone naive `datetime` objects, though this method
handles both time zone naive and aware conversions.
"""
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):
if dttm.tzinfo is not None:
return f"""TIMESTAMP WITH TIME ZONE '{dttm.isoformat(timespec="microseconds", sep=" ")}'"""
return f"""TIMESTAMP '{dttm.isoformat(timespec="microseconds", sep=" ")}'"""
return None Additionally, ensure that both the Apache Superset backend and the database engine are configured to use the same timezone, preferably UTC, to avoid inconsistencies [1][2][3]. For further details, you can refer to the pull requests:
|
I found this issue was related to the bug on this issue was fixed on |
Bug description
when get value with
TIMESTAMP WITH TIME ZONE
type from Trino,db_engine_specs/presto.py
code of Superset cannot handle that value properly. (please see the screenshot below.)I found some issues and MR to fix this issue.
But the modified codes with PR above, is removed on the PR below
How to reproduce the bug
just submit a query like below, to Trino.
you can see the wrong converted results with a margin of error of
32
minutes.(this is not the issue on Trino side, because this issue is not reproduced when I submit a query to same Trino cluster from other tools.)
Screenshots/recordings
Superset version
3.1.3
Python version
3.9
Node version
16
Browser
Chrome
Additional context
https://superset.apache.org/docs/configuration/timezones/
Checklist
The text was updated successfully, but these errors were encountered: