codeant-ai-for-open-source[bot] commented on code in PR #41804:
URL: https://github.com/apache/superset/pull/41804#discussion_r3566639652
##########
superset/models/helpers.py:
##########
@@ -3862,22 +3881,23 @@ def get_sqla_query( # pylint:
disable=too-many-arguments,too-many-locals,too-ma
elif op in {
utils.FilterOperator.ILIKE,
utils.FilterOperator.LIKE,
+ utils.FilterOperator.NOT_LIKE,
+ utils.FilterOperator.NOT_ILIKE,
}:
- if target_generic_type != GenericDataType.STRING:
+ # Native UUID columns report GenericDataType.STRING but
+ # reject LIKE/ILIKE without a cast (see issue #41795)
+ needs_string_cast_for_like = (
+ target_generic_type != GenericDataType.STRING
+ or is_uuid_native_type(col_type)
+ )
Review Comment:
**Suggestion:** Add an explicit type annotation to this newly introduced
local variable so the boolean intent is clear and consistent with the type-hint
requirement. [custom_rule]
**Severity Level:** Minor ๐งน
<details>
<summary><b>Why it matters? โญ </b></summary>
This is newly added Python code that introduces a local boolean variable
without a type annotation, and it can clearly be annotated as bool under the
type-hint rule.
</details>
<details>
<summary><b>Rule source ๐ </b></summary>
.cursor/rules/dev-standard.mdc (line 28)
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=f2fa87c8a0ac458b8ed54e9b0afd4133&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=f2fa87c8a0ac458b8ed54e9b0afd4133&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
*(Use Cmd/Ctrl + Click for best experience)*
<details>
<summary><b>Prompt for AI Agent ๐ค </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset/models/helpers.py
**Line:** 3889:3892
**Comment:**
*Custom Rule: Add an explicit type annotation to this newly introduced
local variable so the boolean intent is clear and consistent with the type-hint
requirement.
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%2F41804&comment_hash=dffecdeb8abd04649330de1dc84832d3c2445715f60409de4c495cf45b9a41ce&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41804&comment_hash=dffecdeb8abd04649330de1dc84832d3c2445715f60409de4c495cf45b9a41ce&reaction=dislike'>๐</a>
##########
tests/unit_tests/models/helpers_test.py:
##########
@@ -3672,3 +3673,75 @@ def
test_temporal_non_numeric_string_filter_is_not_coerced() -> None:
)
assert value == "2025-12-20"
+
+
[email protected](
+ "native_type",
+ ["UUID", "uuid", "Nullable(UUID)"],
+)
[email protected](
+ "op",
+ ["LIKE", "ILIKE", "NOT LIKE", "NOT ILIKE"],
+)
+def test_like_filter_on_uuid_column_casts_to_string(
+ database: Database, native_type: str, op: str
+) -> None:
+ """
+ LIKE-family filters on native UUID columns must cast the column to string.
+
+ UUID columns map to ``GenericDataType.STRING``, so the generic-type guard
+ alone skips the string cast โ but engines such as PostgreSQL and ClickHouse
+ reject LIKE/ILIKE against a raw UUID column (issue #41795: table chart
+ server-pagination search fails with e.g. "Illegal type UUID of argument of
+ function ilike"). The native column type must force the cast.
+ """
+ from superset.connectors.sqla.models import SqlaTable, TableColumn
+
+ table = SqlaTable(
+ database=database,
+ schema=None,
+ table_name="t",
+ columns=[TableColumn(column_name="event_id", type=native_type)],
+ )
+
+ result = table.get_sqla_query(
+ columns=["event_id"],
+ metrics=[],
+ extras={},
+ filter=[{"col": "event_id", "op": op, "val": "abc%"}],
+ granularity=None,
+ is_timeseries=False,
+ orderby=[],
+ )
+ whereclause = result.sqla_query.whereclause
Review Comment:
**Suggestion:** Add an explicit type annotation to this SQLAlchemy
expression variable so the new test code complies with the type-hint
requirement for relevant variables. [custom_rule]
**Severity Level:** Minor ๐งน
<details>
<summary><b>Why it matters? โญ </b></summary>
The new test introduces a local variable that can be type-annotated, but it
is assigned without any type hint. This matches the custom rule requiring type
hints on relevant newly added variables.
</details>
<details>
<summary><b>Rule source ๐ </b></summary>
.cursor/rules/dev-standard.mdc (line 28)
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=3c5883358f754a54bf71f0503203b087&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=3c5883358f754a54bf71f0503203b087&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
*(Use Cmd/Ctrl + Click for best experience)*
<details>
<summary><b>Prompt for AI Agent ๐ค </b></summary>
```mdx
This is a comment left during a code review.
**Path:** tests/unit_tests/models/helpers_test.py
**Line:** 3716:3716
**Comment:**
*Custom Rule: Add an explicit type annotation to this SQLAlchemy
expression variable so the new test code complies with the type-hint
requirement for relevant variables.
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%2F41804&comment_hash=359417f7bd7ba4d612250f54732f2ed3a25d0f84f4109b90d2e51c205eafe4c4&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41804&comment_hash=359417f7bd7ba4d612250f54732f2ed3a25d0f84f4109b90d2e51c205eafe4c4&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]