mirror of
https://github.com/apache/superset.git
synced 2026-07-11 17:25:31 +00:00
feat(semantic layers): dashboard filters (#40475)
This commit is contained in:
@@ -2108,6 +2108,7 @@ def test_get_semantic_view_structure(
|
||||
mock_metric.description = "Order count"
|
||||
|
||||
mock_view = MagicMock()
|
||||
mock_view.name = "orders"
|
||||
mock_view.implementation.get_dimensions.return_value = {mock_dim}
|
||||
mock_view.implementation.get_metrics.return_value = {mock_metric}
|
||||
|
||||
@@ -2120,6 +2121,7 @@ def test_get_semantic_view_structure(
|
||||
|
||||
assert response.status_code == 200
|
||||
result = response.json["result"]
|
||||
assert result["name"] == "orders"
|
||||
assert len(result["dimensions"]) == 1
|
||||
assert result["dimensions"][0]["name"] == "order_date"
|
||||
assert result["dimensions"][0]["type"] == "timestamp[us]"
|
||||
@@ -2202,6 +2204,7 @@ def test_get_semantic_view_structure_no_grain(
|
||||
mock_dim.grain = None
|
||||
|
||||
mock_view = MagicMock()
|
||||
mock_view.name = "customers"
|
||||
mock_view.implementation.get_dimensions.return_value = {mock_dim}
|
||||
mock_view.implementation.get_metrics.return_value = set()
|
||||
|
||||
|
||||
@@ -375,6 +375,28 @@ def test_convert_query_object_filter_in(mock_datasource: MagicMock) -> None:
|
||||
}
|
||||
|
||||
|
||||
def test_convert_query_object_filter_ilike_rejected(
|
||||
mock_datasource: MagicMock,
|
||||
) -> None:
|
||||
"""
|
||||
Case-insensitive operators are rejected explicitly rather than silently
|
||||
collapsed into LIKE — that collapse would let the backend's collation
|
||||
decide case sensitivity, silently diverging from the filter the dashboard
|
||||
author selected.
|
||||
"""
|
||||
all_dimensions = {
|
||||
dim.name: dim for dim in mock_datasource.implementation.dimensions
|
||||
}
|
||||
for op in (FilterOperator.ILIKE.value, FilterOperator.NOT_ILIKE.value):
|
||||
filter_: ValidatedQueryObjectFilterClause = {
|
||||
"op": op,
|
||||
"col": "category",
|
||||
"val": "%book%",
|
||||
}
|
||||
with pytest.raises(ValueError, match="case-insensitive"):
|
||||
_convert_query_object_filter(filter_, all_dimensions)
|
||||
|
||||
|
||||
def test_convert_query_object_filter_is_null(mock_datasource: MagicMock) -> None:
|
||||
"""
|
||||
Test conversion of IS_NULL filter.
|
||||
|
||||
Reference in New Issue
Block a user