From 3fd4718ecb8be2012429bac8a6132f18d8ab7d4a Mon Sep 17 00:00:00 2001 From: Geido <60598000+geido@users.noreply.github.com> Date: Thu, 26 Jan 2023 19:49:44 +0100 Subject: [PATCH] fix: Convert TIMESTAMP_* to TIMESTAMP in Snowflake (#22872) --- .../controls/AnnotationLayerControl/AnnotationLayer.jsx | 2 +- superset/db_engine_specs/snowflake.py | 2 +- tests/unit_tests/db_engine_specs/test_snowflake.py | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/superset-frontend/src/explore/components/controls/AnnotationLayerControl/AnnotationLayer.jsx b/superset-frontend/src/explore/components/controls/AnnotationLayerControl/AnnotationLayer.jsx index bc95bc487ee38..c444e027d9b2b 100644 --- a/superset-frontend/src/explore/components/controls/AnnotationLayerControl/AnnotationLayer.jsx +++ b/superset-frontend/src/explore/components/controls/AnnotationLayerControl/AnnotationLayer.jsx @@ -334,7 +334,7 @@ class AnnotationLayer extends React.PureComponent { ...x, data: { ...x.data, - groupby: x.data.groupby.map(column => + groupby: x.data.groupby?.map(column => getColumnLabel(column), ), }, diff --git a/superset/db_engine_specs/snowflake.py b/superset/db_engine_specs/snowflake.py index 578ded965bed9..cd083a76b2152 100644 --- a/superset/db_engine_specs/snowflake.py +++ b/superset/db_engine_specs/snowflake.py @@ -162,7 +162,7 @@ def convert_dttm( return f"TO_DATE('{dttm.date().isoformat()}')" if tt == utils.TemporalType.DATETIME: return f"""CAST('{dttm.isoformat(timespec="microseconds")}' AS DATETIME)""" - if tt == utils.TemporalType.TIMESTAMP: + if utils.TemporalType.TIMESTAMP in tt: return f"""TO_TIMESTAMP('{dttm.isoformat(timespec="microseconds")}')""" return None diff --git a/tests/unit_tests/db_engine_specs/test_snowflake.py b/tests/unit_tests/db_engine_specs/test_snowflake.py index 854d3f5f61c08..2f1171c33c3d0 100644 --- a/tests/unit_tests/db_engine_specs/test_snowflake.py +++ b/tests/unit_tests/db_engine_specs/test_snowflake.py @@ -34,6 +34,7 @@ ("DATE", "TO_DATE('2019-01-02')"), ("DATETIME", "CAST('2019-01-02T03:04:05.678900' AS DATETIME)"), ("TIMESTAMP", "TO_TIMESTAMP('2019-01-02T03:04:05.678900')"), + ("TIMESTAMP_NTZ", "TO_TIMESTAMP('2019-01-02T03:04:05.678900')"), ], ) def test_convert_dttm(actual: str, expected: str, dttm: datetime) -> None: