codeant-ai-for-open-source[bot] commented on code in PR #45294:
URL: https://github.com/apache/superset/pull/45294#discussion_r4277794042
##########
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:
**Suggestion:** Localized “No filter” values are also treated as empty by
the time parser, but this check misses them and rejects an otherwise no-op
filter on a missing column.
**Assessment:** 🟠 `Major` · 🔁 `Occurrence: Rarely` · 🏷️ `Logic error`
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=4d44622058284c26b51fe6e8d3c757ea&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=4d44622058284c26b51fe6e8d3c757ea&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset/semantic_layers/mapper.py
**Line:** 1432:1434
**Comment:**
*Logic Error: Localized “No filter” values are also treated as empty by
the time parser, but this check misses them and rejects an otherwise no-op
filter on a missing column.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask
user if the user wants to fix the rest of the comments as well. if said yes,
then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F45294&comment_hash=de9a518a7813b88292225311efc5de5e2806a1d046d2ac868efcb51bd1e0fe5b&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F45294&comment_hash=de9a518a7813b88292225311efc5de5e2806a1d046d2ac868efcb51bd1e0fe5b&reaction=dislike'>👎</a>
--
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]