aminghadersohi commented on code in PR #40473:
URL: https://github.com/apache/superset/pull/40473#discussion_r3328083527
##########
superset/mcp_service/dashboard/schemas.py:
##########
@@ -312,6 +339,28 @@ class GetDashboardInfoRequest(MetadataCacheControl):
"from that permalink."
),
)
+ select_columns: Annotated[
+ List[str],
+ Field(
+ default_factory=lambda: list(DEFAULT_GET_DASHBOARD_INFO_COLUMNS),
+ description=(
+ "Top-level fields to include in the response. Defaults to a
lean "
+ "set that excludes 'css' (raw CSS, can be many KB) and
'filter_state' "
+ "(only relevant when permalink_key is provided). Pass an
explicit list "
+ "to override, e.g. ['id','dashboard_title','charts'] for
minimal "
+ "output, or add 'css' to include raw dashboard CSS."
+ ),
+ ),
+ ]
+
+ @field_validator("select_columns", mode="before")
+ @classmethod
+ def _parse_select_columns(cls, value: Any) -> Any:
+ from superset.mcp_service.utils.schema_utils import parse_json_or_list
+
+ if value is None:
+ return list(DEFAULT_GET_DASHBOARD_INFO_COLUMNS)
+ return parse_json_or_list(value, "select_columns")
Review Comment:
Fixed in 3c917c7f99: `_parse_select_columns` now falls back to the lean
default when `parse_json_or_list` returns an empty list (e.g. from `""` or `[]`
input). Same fix applied to chart and dataset schemas and the
`_parse_column_fields` validator.
##########
superset/mcp_service/chart/schemas.py:
##########
@@ -297,6 +331,15 @@ def validate_identifier_or_form_data_key(self) ->
"GetChartInfoRequest":
)
return self
+ @field_validator("select_columns", mode="before")
+ @classmethod
+ def _parse_select_columns(cls, value: Any) -> Any:
+ from superset.mcp_service.utils.schema_utils import parse_json_or_list
+
+ if value is None:
+ return list(DEFAULT_GET_CHART_INFO_COLUMNS)
+ return parse_json_or_list(value, "select_columns")
Review Comment:
Fixed in 3c917c7f99: same empty-list fallback applied.
##########
superset/mcp_service/chart/tool/get_chart_info.py:
##########
@@ -213,7 +214,7 @@ def _apply_unsaved_state_override(result: ChartInfo,
form_data_key: str) -> None
)
async def get_chart_info(
request: GetChartInfoRequest, ctx: Context
-) -> ChartInfo | ChartError:
+) -> dict[str, Any] | ChartError:
Review Comment:
Fixed in 3c917c7f99.
##########
superset/mcp_service/dataset/schemas.py:
##########
@@ -315,13 +334,78 @@ def create(cls, error: str, error_type: str) ->
"DatasetError":
)
+DEFAULT_GET_DATASET_INFO_COLUMNS: List[str] = [
+ "id",
+ "table_name",
+ "schema",
+ "database_name",
+ "database_id",
+ "uuid",
+ "is_virtual",
+ "description",
+ "main_dttm_col",
+ "sql",
+ "url",
+ "columns",
+ "metrics",
+]
+
+DEFAULT_GET_DATASET_INFO_COLUMN_FIELDS: List[str] = [
+ "column_name",
+ "type",
+ "is_dttm",
+]
+
+
class GetDatasetInfoRequest(MetadataCacheControl):
"""Request schema for get_dataset_info with support for ID or UUID."""
identifier: Annotated[
int | str,
Field(description="Dataset identifier - can be numeric ID or UUID
string"),
]
+ select_columns: Annotated[
+ List[str],
+ Field(
+ default_factory=lambda: list(DEFAULT_GET_DATASET_INFO_COLUMNS),
+ description=(
+ "Top-level fields to include in the response. Defaults to a
lean "
+ "set that excludes verbose fields like params,
template_params, "
+ "extra, tags, certification_details. Pass an explicit list to "
+ "override (e.g. ['id','table_name','columns'] for minimal
output)."
+ ),
+ ),
+ ]
+ column_fields: Annotated[
+ List[str],
+ Field(
+ default_factory=lambda:
list(DEFAULT_GET_DATASET_INFO_COLUMN_FIELDS),
+ description=(
+ "Per-column fields to include for entries in 'columns'.
Defaults "
+ "to ['column_name','type','is_dttm']. Pass a wider list to "
+ "include 'verbose_name','groupby','filterable','description' "
+ "when needed."
+ ),
+ ),
+ ]
+
+ @field_validator("select_columns", mode="before")
+ @classmethod
+ def _parse_select_columns(cls, value: Any) -> Any:
+ from superset.mcp_service.utils.schema_utils import parse_json_or_list
+
+ if value is None:
+ return list(DEFAULT_GET_DATASET_INFO_COLUMNS)
+ return parse_json_or_list(value, "select_columns")
Review Comment:
Fixed in 3c917c7f99.
##########
superset/mcp_service/dataset/schemas.py:
##########
@@ -315,13 +334,78 @@ def create(cls, error: str, error_type: str) ->
"DatasetError":
)
+DEFAULT_GET_DATASET_INFO_COLUMNS: List[str] = [
+ "id",
+ "table_name",
+ "schema",
+ "database_name",
+ "database_id",
+ "uuid",
+ "is_virtual",
+ "description",
+ "main_dttm_col",
+ "sql",
+ "url",
+ "columns",
+ "metrics",
+]
+
+DEFAULT_GET_DATASET_INFO_COLUMN_FIELDS: List[str] = [
+ "column_name",
+ "type",
+ "is_dttm",
+]
+
+
class GetDatasetInfoRequest(MetadataCacheControl):
"""Request schema for get_dataset_info with support for ID or UUID."""
identifier: Annotated[
int | str,
Field(description="Dataset identifier - can be numeric ID or UUID
string"),
]
+ select_columns: Annotated[
+ List[str],
+ Field(
+ default_factory=lambda: list(DEFAULT_GET_DATASET_INFO_COLUMNS),
+ description=(
+ "Top-level fields to include in the response. Defaults to a
lean "
+ "set that excludes verbose fields like params,
template_params, "
+ "extra, tags, certification_details. Pass an explicit list to "
+ "override (e.g. ['id','table_name','columns'] for minimal
output)."
+ ),
+ ),
+ ]
+ column_fields: Annotated[
+ List[str],
+ Field(
+ default_factory=lambda:
list(DEFAULT_GET_DATASET_INFO_COLUMN_FIELDS),
+ description=(
+ "Per-column fields to include for entries in 'columns'.
Defaults "
+ "to ['column_name','type','is_dttm']. Pass a wider list to "
+ "include 'verbose_name','groupby','filterable','description' "
+ "when needed."
+ ),
+ ),
+ ]
+
+ @field_validator("select_columns", mode="before")
+ @classmethod
+ def _parse_select_columns(cls, value: Any) -> Any:
+ from superset.mcp_service.utils.schema_utils import parse_json_or_list
+
+ if value is None:
+ return list(DEFAULT_GET_DATASET_INFO_COLUMNS)
+ return parse_json_or_list(value, "select_columns")
+
+ @field_validator("column_fields", mode="before")
+ @classmethod
+ def _parse_column_fields(cls, value: Any) -> Any:
+ from superset.mcp_service.utils.schema_utils import parse_json_or_list
+
+ if value is None:
+ return list(DEFAULT_GET_DATASET_INFO_COLUMN_FIELDS)
+ return parse_json_or_list(value, "column_fields")
Review Comment:
Fixed in 3c917c7f99.
--
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]