bito-code-review[bot] commented on PR #42639:
URL: https://github.com/apache/superset/pull/42639#issuecomment-5143089660
<!-- Bito Reply -->
The flagged issue is correct. The current implementation only handles
columns where `col.type` is explicitly a string type, but it fails for
`literal_column()` objects used in SQL Lab or adhoc-column paths, which are
often untyped even when metadata identifies them as temporal.
To resolve this, you should ensure that the `literal_column` is either
propagated with the correct SQLAlchemy type or that the cast is applied using
the temporal column metadata before `get_timestamp_expr` is called.
Since the current implementation is incomplete, I recommend updating the
logic to check for the presence of temporal metadata on the column object
itself, rather than relying solely on `col.type`.
**superset/db_engine_specs/postgres.py**
```
# ... existing logic ...
if (
time_grain
and pdf not in ("epoch_s", "epoch_ms", "%Y")
and (isinstance(col_type, (String, Text)) or getattr(col,
"is_temporal", False))
):
return TimestampExpression(
expr.name.replace("{col}", "CAST({col} AS TIMESTAMP)"),
col,
type_=DateTime(),
)
```
--
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]