nacretion commented on code in PR #43167:
URL: https://github.com/apache/superset/pull/43167#discussion_r3944610704
##########
tests/unit_tests/db_engine_specs/test_postgres.py:
##########
@@ -418,6 +418,40 @@ def test_get_timestamp_expr_datetime_column_not_cast() ->
None:
assert _compile(expr) == "DATE_TRUNC('day', event_ts)"
+def test_get_timestamp_expr_string_column_casts_to_timestamp() -> None:
+ """DB Eng Specs (postgres): temporal string columns are cast before
truncation."""
+ col = column("event_timestamp", type_=types.String())
+ expr = spec.get_timestamp_expr(col, None, "P1D")
+ assert _compile(expr) == "DATE_TRUNC('day', CAST(event_timestamp AS
TIMESTAMP))"
+
+
+def test_get_timestamp_expr_string_column_without_grain_not_cast() -> None:
+ """DB Eng Specs (postgres): strings without a time grain remain
unchanged."""
+ col = column("event_timestamp", type_=types.String())
+ expr = spec.get_timestamp_expr(col, None, None)
+ assert _compile(expr) == "event_timestamp"
+
+
+def test_get_timestamp_expr_epoch_string_column_not_cast() -> None:
+ """DB Eng Specs (postgres): epoch conversion handles strings before
truncation."""
+ col = column("event_timestamp", type_=types.String())
Review Comment:
Updated in f2c973bda. The docstring now clarifies that the test only ensures
timestamp casts are not added to epoch expressions.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]