aminghadersohi commented on code in PR #42490:
URL: https://github.com/apache/superset/pull/42490#discussion_r3770337634
##########
superset/mcp_service/chart/tool/update_chart_preview.py:
##########
@@ -102,6 +103,49 @@ def _get_previous_form_data(form_data_key: str) ->
dict[str, Any] | None:
return None
+def _preserve_previous_adhoc_filters(
+ new_form_data: dict[str, Any], previous_form_data: dict[str, Any]
+) -> None:
+ """Preserve cached filters without dropping mapper-generated bindings."""
+ previous_filters = previous_form_data.get("adhoc_filters")
+ if not isinstance(previous_filters, list) or not previous_filters:
+ return
+
+ generated_filters = new_form_data.get("adhoc_filters", [])
+ previous_binding =
previous_form_data.get(MCP_DASHBOARD_TIME_FILTER_SUBJECT)
+ new_binding = new_form_data.get(MCP_DASHBOARD_TIME_FILTER_SUBJECT)
+ merged_filters = [
+ filter_
+ for filter_ in previous_filters
+ if not (
+ previous_binding
+ and previous_binding != new_binding
Review Comment:
On a closer provenance audit, this thread identified a real data-loss case,
although the proposed `new_binding is not None` guard would retain genuinely
stale generated bindings. The marker records only the generated subject, so a
user-authored `TEMPORAL_RANGE` on that same subject was also matched by the
removal predicate. I pushed b6fe521f78 to restrict removal to the canonical
mapper-generated `No filter` binding and added a regression covering a
generated binding alongside a user-authored range on the same subject. Leaving
this thread unresolved for review.
--
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]