aminghadersohi commented on code in PR #36458:
URL: https://github.com/apache/superset/pull/36458#discussion_r2599622233
##########
tests/unit_tests/mcp_service/dashboard/tool/test_dashboard_tools.py:
##########
@@ -513,6 +514,96 @@ async def
test_list_dashboards_custom_uuid_slug_columns(mock_list, mcp_server):
assert "slug" in result.data["columns_loaded"]
+class TestDashboardDefaultColumnFiltering:
+ """Test default column filtering behavior for dashboards."""
+
+ def test_minimal_default_columns_constant(self):
+ """Test that minimal default columns are properly defined."""
+ from superset.mcp_service.common.schema_discovery import (
+ DASHBOARD_DEFAULT_COLUMNS,
+ )
+
+ # Should have exactly 4 minimal columns
+ assert len(DASHBOARD_DEFAULT_COLUMNS) == 4
+ assert set(DASHBOARD_DEFAULT_COLUMNS) == {
+ "id",
+ "dashboard_title",
+ "slug",
+ "uuid",
+ }
+
+ # Heavy columns should NOT be in defaults
+ assert "charts" not in DASHBOARD_DEFAULT_COLUMNS
+ assert "published" not in DASHBOARD_DEFAULT_COLUMNS
+ assert "json_metadata" not in DASHBOARD_DEFAULT_COLUMNS
+ assert "position_json" not in DASHBOARD_DEFAULT_COLUMNS
+
+ def test_empty_select_columns_default(self):
+ """Test that select_columns defaults to empty list which triggers
+ minimal defaults in tool."""
+ request = ListDashboardsRequest()
+ assert request.select_columns == []
+
+ def test_explicit_select_columns(self):
+ """Test that explicit select_columns can include non-default
columns."""
+ request = ListDashboardsRequest(
+ select_columns=["id", "dashboard_title", "published", "charts"]
+ )
+ assert "published" in request.select_columns
+ assert "charts" in request.select_columns
+ # These are explicitly requested, not defaults
+ assert len(request.select_columns) == 4
+
+ @patch("superset.daos.dashboard.DashboardDAO.list")
+ @pytest.mark.asyncio
+ async def test_default_columns_in_response(self, mock_list, mcp_server):
+ """Test that minimal default columns appear in response metadata."""
+ dashboard = Mock()
+ dashboard.id = 1
+ dashboard.dashboard_title = "Test Dashboard"
+ dashboard.slug = "test-dashboard"
+ dashboard.uuid = "test-uuid-123"
+ dashboard.url = "/dashboard/1"
+ dashboard.published = True
+ dashboard.changed_by_name = "admin"
+ dashboard.changed_on = None
+ dashboard.changed_on_humanized = None
+ dashboard.created_by_name = "admin"
+ dashboard.created_on = None
+ dashboard.created_on_humanized = None
+ dashboard.tags = []
+ dashboard.owners = []
+ dashboard.slices = []
+ dashboard.description = None
+ dashboard.css = None
+ dashboard.certified_by = None
+ dashboard.certification_details = None
+ dashboard.json_metadata = None
+ dashboard.position_json = None
+ dashboard.is_managed_externally = False
+ dashboard.external_url = None
+ dashboard.thumbnail_url = None
+ dashboard.roles = []
+ dashboard.charts = []
+ mock_list.return_value = ([dashboard], 1)
Review Comment:
The tests pass with the current implementation. The serialization uses
`serialize_dashboard_object()` which doesn't rely on `_mapping` - it extracts
fields directly from the object attributes.
##########
superset/mcp_service/system/tool/get_schema.py:
##########
@@ -0,0 +1,142 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""
+Unified schema discovery tool for MCP service.
+
+This tool consolidates schema discovery for all model types (chart, dataset,
+dashboard) into a single endpoint, reducing token usage and API calls.
+"""
+
+import logging
+from typing import Literal
Review Comment:
Not applicable - the implementation doesn't use `asyncio.to_thread`. The
core classes are synchronous and the tool function just awaits the result
directly.
--
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]