bito-code-review[bot] commented on PR #44720:
URL: https://github.com/apache/superset/pull/44720#issuecomment-5851370635
<!-- Bito Reply -->
The flagged issue is correct. The current implementation of
`alter_new_orm_column` only updates the `python_date_format` for new columns
being created, leaving existing columns with their original (potentially null
or incorrect) formats.
To resolve this, you should ensure that the `python_date_format` is only
updated if it is currently unset or if the column type explicitly requires the
`epoch_ms` format. You can modify the logic in
`superset/db_engine_specs/crate.py` as follows:
```python
@classmethod
def alter_new_orm_column(cls, orm_col: TableColumn) -> None:
if orm_col.type in {
"TIMESTAMP",
"TIMESTAMP WITHOUT TIME ZONE",
"TIMESTAMP WITH TIME ZONE",
} and not orm_col.python_date_format:
orm_col.python_date_format = "epoch_ms"
```
This change ensures that existing formats are preserved while correctly
setting the format for new timestamp columns. Would you like me to fetch all
other comments on this PR to validate and implement fixes for them as well?
**superset/db_engine_specs/crate.py**
```
@classmethod
def alter_new_orm_column(cls, orm_col: TableColumn) -> None:
if orm_col.type in {
"TIMESTAMP",
"TIMESTAMP WITHOUT TIME ZONE",
"TIMESTAMP WITH TIME ZONE",
} and not orm_col.python_date_format:
orm_col.python_date_format = "epoch_ms"
```
--
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]