aminghadersohi commented on code in PR #44265:
URL: https://github.com/apache/superset/pull/44265#discussion_r4034959120


##########
superset/mcp_service/semantic_layer/tool/get_table.py:
##########
@@ -322,6 +326,30 @@ async def _run_get_table_query(
             error_type="ValidationError",
         )
 
+    required_dimensions: set[str] = set(request.dimensions) | {
+        query_filter.col for query_filter in request.filters
+    }

Review Comment:
   `order_by` names land in the same dimension position 
(`_get_order_from_query_object` binds them via `all_dimensions`), so they still 
bypass this. Measured: `order_by=['product_name']` executes unguarded. 
Intersecting with `valid_columns` keeps metric ordering working.
   ```suggestion
       required_dimensions: set[str] = (
           set(request.dimensions)
           | {query_filter.col for query_filter in request.filters}
           | (set(request.order_by) & resolved.valid_columns)
       )
   ```



##########
superset/mcp_service/semantic_layer/tool/get_table.py:
##########
@@ -322,6 +326,30 @@ async def _run_get_table_query(
             error_type="ValidationError",
         )
 
+    required_dimensions: set[str] = set(request.dimensions) | {
+        query_filter.col for query_filter in request.filters
+    }
+    if (
+        not is_builtin
+        and resolved.view is not None
+        and request.metrics
+        and required_dimensions
+    ):
+        compatible: set[str] = set(
+            resolved.view.get_compatible_dimensions(request.metrics, [])
+        )
+        incompatible: list[str] = sorted(required_dimensions - compatible)

Review Comment:
   Including `filters[].col` makes the two temporal forms diverge: a 
`TEMPORAL_RANGE` filter on `order_ts` is now rejected, while 
`time_column="order_ts"` + `time_range` — which `_build_query_dict` turns into 
that exact filter — still passes. Measured both.



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