Abdulrehman-PIAIC80387 commented on code in PR #42793:
URL: https://github.com/apache/superset/pull/42793#discussion_r3735390144
##########
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:
Fixed in `123746ca1e`. Replaced the formula-based expected with fixed sha256
literals (`create_time` → `create_time_b09621`, `revenue` → `revenue_371f7e`,
`sum(A)/sum(B)` → `sum(A)/sum(B)_f0ea8d`) and patched `get_hash_algorithm` to
`sha256` so the assertion stays stable regardless of operator config.
Also hardened `test_..._is_deterministic` and
`test_..._is_unique_across_inputs` with `startswith(label + "_")` checks per
your own observation — they no longer pass against an identity `_mutate_label`.
Verified locally by reverting the production override: all three tests now fail
as intended.
--
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]