mikebridge commented on code in PR #45294:
URL: https://github.com/apache/superset/pull/45294#discussion_r4284450845
##########
superset/semantic_layers/mapper.py:
##########
@@ -1392,22 +1393,45 @@ def validate_filter_columns(
dimension_names: Collection[str],
metric_names: Collection[str],
) -> None:
- """Refuse chart-defined metric predicates; report incompatible extras
later."""
+ """Refuse chart-defined predicates on metrics or on columns the view lacks.
+
+ Dashboard (``isExtra``) filters are not refused: incompatible ones are
+ skipped and reported, so a dashboard filter cannot break the chart. A
+ "No filter" time range constrains nothing, so its column is not checked.
+ """
for filter_ in filters:
column: Column = filter_["col"]
if (
- isinstance(column, str)
- and column not in dimension_names
- and column in metric_names
- and not filter_.get("isExtra")
+ not isinstance(column, str)
+ or column in dimension_names
+ or filter_.get("isExtra")
+ or _is_no_op_time_range(filter_)
):
+ continue
+ if column in metric_names:
raise QueryObjectValidationError(
_(
"Filter column '%(column)s' is a metric; semantic views
only "
- "filter on dimensions",
+ "filter on dimensions. Select a dimension or remove the
filter.",
column=column,
)
)
+ raise QueryObjectValidationError(
+ _(
+ "Filter column '%(column)s' is not in this semantic view.
Select a "
+ "dimension or remove the filter.",
+ column=column,
+ )
+ )
+
+
+def _is_no_op_time_range(
+ filter_: QueryObjectFilterClause | ValidatedQueryObjectFilterClause,
+) -> bool:
+ """Whether a filter is a time range that applies no bounds."""
+ return filter_.get("op") == FilterOperator.TEMPORAL_RANGE.value and
filter_.get(
+ "val"
+ ) in (None, NO_TIME_RANGE)
Review Comment:
Fixed in
https://github.com/apache/superset/commit/9ae3a13aa5ce860f1801b97aa7fae8f09418b9b8:
shared locale-aware recognition with a red-first HTTP regression test (Codex).
--
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]