tien238lnd commented on code in PR #45175:
URL: https://github.com/apache/superset/pull/45175#discussion_r4441867681
##########
superset/commands/datasource/list.py:
##########
@@ -298,63 +384,83 @@ def _apply_sql_null_filter(
return type_filter, sql_filter
@staticmethod
- def _parse_filters(
- filters: list[dict[str, Any]],
- ) -> tuple[
- str, str | None, bool | None, str | None, int | None, str | None, str
| None
- ]:
+ def _parse_legacy_filter(
+ col: str, opr: Any, value: Any, current: dict[str, Any]
+ ) -> dict[str, Any]:
+ """Parse the columns the combined list has filtered on from the start.
+
+ An operator other than the one the column is applied with, or a value
+ that cannot be read, raises instead of being dropped: a dropped filter
+ returns an unfiltered list that looks filtered. A ``None`` value is
+ "no filter", as the Datasets page never sends one. ``current`` carries
+ the fields parsed so far, for the ``sql`` filter that updates two of
+ them at once.
"""
- Translate raw rison filter dicts into typed query parameters.
-
- Returns:
- source_type: "all" | "database" | "semantic_layer"
- name_filter: substring to match against name/table_name
- sql_filter: True → physical only, False → virtual only,
None → both
- type_filter: "semantic_view" when caller wants only
- semantic views
- database_id: filter datasets to a specific database ID
- semantic_layer_uuid: filter semantic views to a specific semantic
layer UUID
- schema_filter: filter datasets to a specific schema name
+ if opr != _LEGACY_OPERATORS[col]:
+ raise ValueError(f"Filter operation: {opr} not allowed on column:
{col}")
+ if col == "source_type":
+ return {"source_type": value or "all"}
+ if value is None:
+ return {}
+ if col == "table_name":
+ return {"name_filter": value}
Review Comment:
Done in 2a60174db0: `table_name` must be text and `semantic_layer_uuid` must
parse as a UUID, both answered with the same `400 Invalid value for filter
column` as `database` instead of a 500 at query time. The malformed values test
has a row each for a number, a list, a non-UUID string and a number as the
layer, and there is a positive test for a text name and a real UUID.
_🤖 Addressed by [Claude Code](https://claude.com/claude-code)_
--
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]