sadpandajoe commented on code in PR #45671:
URL: https://github.com/apache/superset/pull/45671#discussion_r4402224155
##########
superset/utils/date_parser.py:
##########
@@ -846,8 +858,13 @@ def eval(self) -> datetime:
month=1, day=1, hour=0, minute=0, second=0, microsecond=0
)
if unit == "quarter":
- dttm = (
- pd.Period(pd.Timestamp(dttm),
freq="Q").to_timestamp().to_pydatetime()
+ dttm = dttm.replace(
Review Comment:
Now that a quarter keeps its offset, `DATEDIFF` (this file,
`EvalDateDiffFunc`) subtracts an aware value from a naive one and raises
`TypeError`. For example,
`DATEDIFF(DATETRUNC(DATETIME('2024-05-31T12:00:00+08:00'), QUARTER),
DATETIME('2024-06-01'))` returned 61 before this change and now fails, so a
saved custom range that nests it (e.g. inside `DATEADD`) breaks. Should
`DATEDIFF` use `get_comparable_bounds` like the other consumers?
##########
superset/models/helpers.py:
##########
@@ -3282,12 +3290,18 @@ def get_offset_custom_or_inherit(
# the range against itself, and a 36-hour range would shift by a
# single day and overlap it. Whole-day ranges resolve to the same
# instant either way.
- duration = outer_to_dttm - outer_from_dttm
+ from_comparison, to_comparison = get_comparable_bounds(
Review Comment:
`get_offset_custom_or_inherit` now accepts aware bounds, but the caller
(`get_past_or_future` at ~L3004) rebuilds the shifted bounds from `timetuple()`
and returns naive datetimes. With dataset timezone `Europe/Berlin` and a
`+08:00` quarter start, the main period is filtered from 16:00Z while its `1
year ago` comparison starts at 22:00Z, so the two periods are not shifted by
the same amount. Should the shifted bounds keep the original offset?
--
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]