aminghadersohi commented on code in PR #43770:
URL: https://github.com/apache/superset/pull/43770#discussion_r4226256911
##########
superset/mcp_service/chart/preview_utils.py:
##########
@@ -1398,6 +2413,137 @@ def fallback_vega_lite_preview(
return None
+def _xy_pivot_x_type(values: list[Any]) -> str:
+ """Infer the Vega-Lite x type from every x value, not a character scan.
+
+ The renderer has no column metadata, so text is temporal only when each
+ value parses as an ISO date or datetime; labels such as ``New York`` stay
+ nominal instead of becoming unparseable dates.
+ """
+ present = [value for value in values if value is not None]
+ if not present:
+ return "nominal"
+ if all(
+ isinstance(value, (int, float)) and not isinstance(value, bool)
+ for value in present
+ ):
+ return "quantitative"
+ if all(
+ isinstance(value, (date, datetime))
+ or (isinstance(value, str) and _gantt_temporal_value(value) is not
None)
Review Comment:
Confirmed: `datetime.fromisoformat` accepts basic-format (`20250101`,
`2025-01-01T000000`) and week dates (`2025-W01-1`), and `Date.parse` returns
NaN for all of them. Fixed in 4d0ef0f964051990f0e86e9583c04a8d8eccc604:
`_xy_pivot_x_type` marks text temporal only when every value fully matches the
extended ISO form (`YYYY-MM-DD` with optional `T`/space time, fractional
seconds and `Z`/`±HH:MM` offset) and still parses; anything else falls back to
`nominal`. `test_xy_preview_x_type_requires_parseable_dates` adds compact,
mixed, week-date, basic-time and invalid-month cases (4 of them fail without
the fix), plus extended forms that stay temporal.
##########
superset/mcp_service/semantic_layer/tool/get_table.py:
##########
@@ -509,33 +563,38 @@ async def _run_get_table_query(
use_cache=request.use_cache,
force=request.force_refresh,
)
+ extracted = _extract_table_query_result(result)
+ if isinstance(extracted, SemanticLayerError):
+ return extracted
+ query_result, data, raw_columns, coltypes = extracted
query_duration_ms = int((time.time() - start_time) * 1000)
- if not result or "queries" not in result or not result["queries"]:
- return SemanticLayerError.create(
- error="Query returned no results.",
- error_type="EmptyQuery",
- )
-
await ctx.report_progress(5, 5, "Formatting results")
- query_result = result["queries"][0]
response = _build_response(
request,
is_builtin,
resolved.display_name,
query_result,
+ data,
+ raw_columns,
+ coltypes,
query_duration_ms,
resolved.warnings,
resolved.temporal_columns,
resolved.valid_grains,
)
+ if response_failure := response_json_failure(response):
Review Comment:
Added in 4d0ef0f964051990f0e86e9583c04a8d8eccc604:
`test_get_table_rejects_response_amplified_by_column_profiling` sends 255 rows,
each with a distinct ~64 KiB `category` cell. The test asserts that
`query_result_data` accepts the source result, so source validation passes. It
then wraps `response_json_failure` to confirm the post-format guard is reached
and returns the failure, and asserts a `MalformedQueryResult` byte-limit error
with no `data`/`columns`. With the guard block disabled, the test fails.
--
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]