Skip to content

Commit

Permalink
fix: Convert TIMESTAMP_* to TIMESTAMP in Snowflake (apache#22872)
Browse files Browse the repository at this point in the history
  • Loading branch information
geido authored and PawankumarES committed Feb 13, 2023
1 parent 55080b5 commit 1ee1911
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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),
),
},
Expand Down
2 changes: 1 addition & 1 deletion superset/db_engine_specs/snowflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions tests/unit_tests/db_engine_specs/test_snowflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 1ee1911

Please sign in to comment.