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


##########
superset/mcp_service/semantic_layer/tool/get_table.py:
##########
@@ -180,8 +194,42 @@ def _resolve_external_view(
             error_type="ValidationError",
         )
 
+    valid_grains: dict[str, str] = {
+        duration: grain["name"]
+        for grain in view.get_time_grains()
+        if (duration := grain["duration"]) is not None
+    }
+    grain_column: str | None = request.time_column

Review Comment:
   With `time_range` set and `time_column` omitted, `time_col` and 
`grain_column` can differ: verified `granularity=metric_time` while 
BASE_AXIS/`timeGrain` sits on `signup_date`. `_get_grain_time_axis_column` 
returns `granularity` first (mapper.py:1054-1055), so the grain is dropped.



##########
superset/mcp_service/utils/response_utils.py:
##########
@@ -195,6 +200,8 @@ def format_data_columns(
                 data_type = "boolean"
             elif all(isinstance(v, (int, float)) for v in sample_values):
                 data_type = "numeric"
+        if temporal_columns and col_name in temporal_columns:
+            data_type = "datetime"

Review Comment:
   `get_chart_data` already ships `data_type="temporal"` for this concept via 
`_GENERIC_TYPE_MAP`; `get_table` now ships `"datetime"` in the same 
`DataColumn` field, so one MCP surface publishes two words for one type. No 
suggestion fence: this PR's tests assert `"datetime"`.



##########
superset/mcp_service/semantic_layer/tool/get_table.py:
##########
@@ -180,8 +194,42 @@ def _resolve_external_view(
             error_type="ValidationError",
         )
 
+    valid_grains: dict[str, str] = {
+        duration: grain["name"]
+        for grain in view.get_time_grains()

Review Comment:
   `get_time_grains()` unions grains across all temporal dimensions 
(models.py:708), so a grain validates here even when `grain_column` has no such 
variant; the mapper then falls back silently (mapper.py:388-398). Verified: 
union `['P1D','P1M','P1Y']`, `signup_date` (P1D/P1Y) accepts P1M.



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