aminghadersohi commented on code in PR #44393:
URL: https://github.com/apache/superset/pull/44393#discussion_r4150447993
##########
superset/mcp_service/chart/schemas.py:
##########
@@ -3783,6 +3784,32 @@ def chart_config_reference_schema(*, nullable: bool =
False) -> WithJsonSchema:
}
+def _normalize_chart_target_alias(data: dict[str, Any]) -> dict[str, Any]:
+ """Copy legacy target vocabulary without changing its datasource family."""
+ data = dict(data)
+ if "datasource_type" in data and (
+ (data.get("dataset_id") is not None and data["datasource_type"] !=
"table")
+ or (
+ data.get("view_id") is not None
+ and data["datasource_type"] != "semantic_view"
+ )
+ ):
+ raise ValueError("datasource_type conflicts with the explicit chart
target")
+ if "datasource_id" in data:
+ source_type: object = data.get("datasource_type", "table")
+ if source_type not in ("table", "semantic_view"):
+ raise ValueError("datasource_type must be table or semantic_view")
+ target_key: str = "view_id" if source_type == "semantic_view" else
"dataset_id"
+ other_key: str = "dataset_id" if target_key == "view_id" else "view_id"
+ source_id: object = data.pop("datasource_id")
+ if data.get(other_key) is not None or (
+ data.get(target_key) is not None and data[target_key] != source_id
+ ):
+ raise ValueError("datasource_id conflicts with the explicit chart
target")
Review Comment:
This rejects `{"dataset_id": 7, "datasource_id": 23}`, which master's
`test_dataset_id_wins_over_datasource_id` (test_chart_config_coercion.py:58)
pins as `dataset_id == 7`: it passes on master and fails here. That file is
outside the diff, so no suggestion.
--
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]