mirror of
https://github.com/apache/superset.git
synced 2026-04-22 17:45:21 +00:00
fix(mcp): support explicit query_mode in TableChartConfig (#39412)
This commit is contained in:
committed by
GitHub
parent
e5b3a9c25d
commit
2e0d482ccf
@@ -390,6 +390,62 @@ class TestMapTableConfig:
|
||||
assert result["metrics"] == ["total_revenue", "avg_order_value"]
|
||||
assert "all_columns" not in result
|
||||
|
||||
def test_map_table_config_explicit_raw_mode(self) -> None:
|
||||
"""Test that explicit query_mode='raw' forces raw mode."""
|
||||
config = TableChartConfig(
|
||||
chart_type="table",
|
||||
query_mode="raw",
|
||||
columns=[
|
||||
ColumnRef(name="product"),
|
||||
ColumnRef(name="category"),
|
||||
],
|
||||
)
|
||||
|
||||
result = map_table_config(config)
|
||||
|
||||
assert result["viz_type"] == "table"
|
||||
assert result["query_mode"] == "raw"
|
||||
assert result["all_columns"] == ["product", "category"]
|
||||
assert result["columns"] == ["product", "category"]
|
||||
assert "metrics" not in result
|
||||
|
||||
def test_map_table_config_explicit_raw_mode_ignores_aggregates(self) -> None:
|
||||
"""Test that explicit query_mode='raw' ignores aggregate settings on columns."""
|
||||
config = TableChartConfig(
|
||||
chart_type="table",
|
||||
query_mode="raw",
|
||||
columns=[
|
||||
ColumnRef(name="product"),
|
||||
ColumnRef(name="sales", aggregate="SUM"),
|
||||
],
|
||||
)
|
||||
|
||||
result = map_table_config(config)
|
||||
|
||||
assert result["query_mode"] == "raw"
|
||||
# Both columns treated as raw; aggregate setting on "sales" is ignored
|
||||
assert result["all_columns"] == ["product", "sales"]
|
||||
assert result["columns"] == ["product", "sales"]
|
||||
assert "metrics" not in result
|
||||
|
||||
def test_map_table_config_explicit_aggregate_mode(self) -> None:
|
||||
"""Test that explicit query_mode='aggregate' uses inference logic."""
|
||||
config = TableChartConfig(
|
||||
chart_type="table",
|
||||
query_mode="aggregate",
|
||||
columns=[
|
||||
ColumnRef(name="product"),
|
||||
ColumnRef(name="revenue", aggregate="SUM"),
|
||||
],
|
||||
)
|
||||
|
||||
result = map_table_config(config)
|
||||
|
||||
assert result["query_mode"] == "aggregate"
|
||||
assert len(result["metrics"]) == 1
|
||||
assert result["metrics"][0]["aggregate"] == "SUM"
|
||||
assert "product" in result["groupby"]
|
||||
|
||||
|
||||
class TestAddAdhocFilters:
|
||||
"""Test _add_adhoc_filters helper function"""
|
||||
|
||||
Reference in New Issue
Block a user