porkedchop opened a new pull request, #45344:
URL: https://github.com/apache/superset/pull/45344
### SUMMARY
#37014 added a dataset timezone (`"timezone"` in the dataset's extra).
`normalize_dttm_col` applies it by localizing the column to UTC and then
converting it to that timezone.
That assumes the values are naive. Columns of a timezone-aware type, like
Postgres `timestamptz`, BigQuery `TIMESTAMP` or ClickHouse `DateTime64` with a
zone, come out of `SupersetResultSet` as `datetime64[ns, tz]`, and
`tz_localize("UTC")` raises `TypeError: Already tz-aware, use tz_convert to
convert.` on them. So once a timezone is set on such a dataset, charts that
return the column fail.
This only localizes naive values to UTC and converts tz-aware values as they
are. Naive columns behave the same as before.
This touches the same block as #45203 (DATE columns), but the two changes
are independent.
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A
### TESTING INSTRUCTIONS
1. On a Postgres dataset with a `timestamptz` column, set the dataset extra
to `{"timezone": "America/New_York"}`.
2. Build a table chart that includes the column.
3. Before: the chart fails with "Already tz-aware". After: the values are
shown in New York time.
`pytest tests/unit_tests/utils/test_core.py -k tz_aware` fails on master and
passes with this change.
### ADDITIONAL INFORMATION
- [ ] Has associated issue:
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration (follow approval process in
[SIP-59](https://github.com/apache/superset/issues/13351))
- [ ] Migration is atomic, supports rollback & is backwards-compatible
- [ ] Confirm DB migration upgrade and downgrade tested
- [ ] Runtime estimates and downtime expectations provided
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
--
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]