FrancescoCastaldi commented on issue #45796:
URL: https://github.com/apache/superset/issues/45796#issuecomment-6524015468
### Root Cause Analysis & Solution
In `superset/common/query_context_processor.py:get_viz_annotation_data`,
chart annotation queries fail to apply "Override time range" and "Override time
grain" controls:
1. When "Inherit from host chart" is selected (storing `null` in form data),
`get_viz_annotation_data` lacked the host `query_obj` and discarded the
inheritance.
2. When an explicit override was provided, the function updated legacy
`from_dttm` and `to_dttm` attributes on the annotation query, leaving the
modern `TEMPORAL_RANGE` adhoc filter and generic x-axis `timeGrain` untouched.
#### Solution
1. Pass the host `query_obj` to `get_viz_annotation_data`.
2. When `overrides.get("time_range") is None`, inherit `time_range` directly
from `query_obj.time_range`.
3. Locate the `FilterOperator.TEMPORAL_RANGE` filter in
`annotation_query_obj.adhoc_filters` and update its comparator value with the
resolved time range.
4. If `time_grain_sqla` is overridden or inherited, update the time grain on
the corresponding x-axis column.
Verified with unit tests in
`tests/unit_tests/common/test_query_context_processor.py` and committed to
branch `fix/community-unanswered-issues` (commit `d312a4cd2ee`) at
https://github.com/FrancescoCastaldi/superset/tree/fix/community-unanswered-issues.
--
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]