rebenitez1802 commented on code in PR #45571:
URL: https://github.com/apache/superset/pull/45571#discussion_r4361344169


##########
superset/common/query_context_factory.py:
##########
@@ -433,6 +437,13 @@ def _apply_granularity(  # noqa: C901
                     filter
                     for filter in query_object.filter
                     if filter["col"] != filter_to_remove
+                    or (
+                        filter["op"] != "TEMPORAL_RANGE"
+                        and (
+                            filter_to_remove == granularity
+                            or (form_data or {}).get("viz_type") == 
"sunburst_v2"

Review Comment:
   🔴 High — The Sunburst exception keeps stale dashboard cross-filters from a 
swapped x-axis
   The exception keeps every non-range filter on the replaced column, and that 
includes filters coming from the dashboard. Here is how a stale one arrives:
   - A dashboard Time Column filter set to `ship_date` swaps a Timeseries/Bar 
chart's forced-categorical `order_date` x-axis to `ship_date`, but the axis 
keeps its `order_date` label (lines 384-395).
   - Clicking a bar on that chart emits `{col: "order_date", op: "IN", val: 
[<ship_date value>]}` (`EchartsTimeseries.tsx:403-415`), and `buildQueryObject` 
tags it `isExtra`.
   - A Sunburst on the same dashboard whose own range filter is on `order_date` 
now keeps that cross-filter, so it filters `order_date` by a `ship_date` value. 
Master dropped it.
   
   Repro through `QueryContextFactory.create`, using the `events_table` fixture 
plus one row ordered 2026-08-01 12:00 and shipped 2026-12-25: a cross-filter 
from the ship-date bar at 2026-08-01 12:00 makes the Sunburst return the order 
*placed* at that time (`{'z': 1}`) instead of the one shipped then. This 
happens for samples, drill_detail and full.
   
   The Sunburst's own Drill to detail and Drill by filters never carry 
`isExtra`. So limiting the exception to non-extra filters keeps your fix and 
restores master behaviour for dashboard filters. With this suggestion applied:
   - the stale filter is dropped;
   - the Sunburst drill under a different Time Column still returns exactly its 
bucket rows;
   - the same-column and Timeseries cases are unchanged;
   - the PR's test files pass, and ruff 0.9.7 is clean.
   
   A factory test with an `isExtra` filter on the replaced column would pin 
this.
   
   ```suggestion
                               or (
                                   (form_data or {}).get("viz_type") == 
"sunburst_v2"
                                   # Dashboard filters can come from a swapped 
x-axis.
                                   and not filter.get("isExtra")
                               )
   ```
   



-- 
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]

Reply via email to