codeant-ai-for-open-source[bot] commented on code in PR #42793:
URL: https://github.com/apache/superset/pull/42793#discussion_r3719390952
##########
tests/unit_tests/db_engine_specs/test_clickhouse.py:
##########
@@ -616,3 +616,45 @@ def test_use_equality_for_boolean_filters_property() ->
None:
from superset.db_engine_specs.clickhouse import ClickHouseBaseEngineSpec
assert ClickHouseBaseEngineSpec.use_equality_for_boolean_filters is True
+
+
+def test_clickhouse_mutate_label_suffixes_hash() -> None:
+ """Regression test for #40289.
+
+ ``_mutate_label`` must append a 6-char hash suffix so that column
+ aliases in ``SELECT expr AS alias`` never collide lexically with
+ subquery column names of the same name. Without this suffix,
+ ClickHouse 25.3+ raises ``Code: 215`` on charts against virtual
+ datasets, even though the SELECT and GROUP BY expressions are
+ lexically identical.
+ """
+ from superset.db_engine_specs.clickhouse import ClickHouseBaseEngineSpec
+ from superset.utils.hashing import hash_from_str
+
+ for label in ("create_time", "revenue", "sum(A)/sum(B)"):
+ expected = f"{label}_{hash_from_str(label)[:6]}"
+ assert ClickHouseBaseEngineSpec._mutate_label(label) == expected
Review Comment:
**Suggestion:** The expected value is computed with the same `hash_from_str`
implementation used by production, so this assertion cannot detect an incorrect
hash algorithm, input, or suffix contract. Use a fixed expected digest or
assert the externally required alias value independently of the implementation
under test. [code quality]
<details>
<summary><b>Severity Level:</b> Minor ๐งน</summary>
```mdx
- โ ๏ธ Hash or suffix regressions can evade unit-test detection.
- โ ๏ธ ClickHouse alias compatibility remains coupled to implementation
details.
- โ ๏ธ Production alias generation is used through
`BaseEngineSpec.make_label_compatible()` at
`superset/db_engine_specs/base.py:2347-2348`.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=93d5de5c39ef42868a1d6d2fd3444e4f&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=93d5de5c39ef42868a1d6d2fd3444e4f&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/db_engine_specs/test_clickhouse.py
**Line:** 635:636
**Comment:**
*Code Quality: The expected value is computed with the same
`hash_from_str` implementation used by production, so this assertion cannot
detect an incorrect hash algorithm, input, or suffix contract. Use a fixed
expected digest or assert the externally required alias value independently of
the implementation under test.
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%2F42793&comment_hash=ae86965a7fe9c35daeb021be86db54000082585df1c464f429fa20d6065a9a79&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42793&comment_hash=ae86965a7fe9c35daeb021be86db54000082585df1c464f429fa20d6065a9a79&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]