fix(clickhouse): remove _mutate_label workaround and bump clickhouse-connect to >=0.13.0 - #38280
Conversation
Code Review Agent Run #8f7c6bActionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Hi @rusackas, I chatted offline with @villebro and he advised that the problem can be solved directly in |
|
@sadpandajoe this is an important fix for ClickHouse users, so if there's a 6.0.1-rc2 forthcoming, please pull this one in! |
|
Bito Automatic Review Skipped – PR Already Merged |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #38280 +/- ##
==========================================
+ Coverage 64.11% 64.87% +0.76%
==========================================
Files 1810 2482 +672
Lines 71175 122996 +51821
Branches 22650 28515 +5865
==========================================
+ Hits 45631 79793 +34162
- Misses 25544 41806 +16262
- Partials 0 1397 +1397
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…connect to >=0.13.0 (apache#38280)
|
Looks like this change now brings problems due to a Clickhouse setting prefer_column_name_to_alias Its default value is 0, so "The column name is substituted with the alias." I'm now testing my charts on Superset 6.1.0 and this removal of random suffixes in column aliases leads to the scenario when applied Time Range filters implicitly depend on a Granularity filter. E.g. I set values in a Time Range filter: Start 2026-06-10 (which was Wednesday) - End 2026-07-08
Everything is ok.
Due to the prefer_column_name_to_alias=0, the minimal day, included into the results is 2026-06-15, and the whole week before that Monday disappears from the results, while I didn't touch Time Range filter and "Actual Time Range" still says me it should be there.
So only results for July are shown. In Superset 4.1.2, which we have on prod now, there's no such issue, cause the resulted query is always like so dynamic column aliases do not affect filters. Did I miss anything about this update? |
|
Hi @ivkhokhlachev did you try setting
I ran an test locally and I think that'll solve the issue. It's probably worth a followup PR to default that value to 1 in the engine spec. |
|
Hi @ivkhokhlachev , thanks for the detailed write-up. I agree with @joe-clickhouse that setting it by default to 1 is the correct way to address this, as Superset heavily depends on this assumption. I think the best solution would be to default |
Applies the pre-apache#38280 6-char hash suffix to column aliases on both ``ClickHouseEngineSpec`` (clickhouse-sqlalchemy) and ``ClickHouseConnectEngineSpec`` by placing the ``_mutate_label`` override on the shared ``ClickHouseBaseEngineSpec``. Fixes ClickHouse 25.3+ raising ``Code: 215`` on charts against virtual datasets when the outer alias collides lexically with a subquery column name. Also addresses @ivkhokhlachev's related regression on the apache#38280 thread where time-range filters silently narrow when the granularity changes (same root cause: alias == subquery column name → ClickHouse's ``prefer_column_name_to_alias=0`` substitutes the aliased expression into the WHERE clause). Documented in UPDATING.md: cached results keyed on the old aliases will miss the cache once on upgrade, exported CSV/XLSX column names for ClickHouse charts include the suffix, and any downstream consumer that parses column headers will see the new names. Fixes apache#40289
Applies the pre-apache#38280 6-char hash suffix to column aliases on both ``ClickHouseEngineSpec`` (clickhouse-sqlalchemy) and ``ClickHouseConnectEngineSpec`` by placing the ``_mutate_label`` override on the shared ``ClickHouseBaseEngineSpec``. Fixes ClickHouse 25.3+ raising ``Code: 215`` on charts against virtual datasets when the outer alias collides lexically with a subquery column name. Also addresses @ivkhokhlachev's related regression on the apache#38280 thread where time-range filters silently narrow when the granularity changes (same root cause: alias == subquery column name → ClickHouse's ``prefer_column_name_to_alias=0`` substitutes the aliased expression into the WHERE clause). Documented in UPDATING.md: cached results keyed on the old aliases will miss the cache once on upgrade, exported CSV/XLSX column names for ClickHouse charts include the suffix, and any downstream consumer that parses column headers will see the new names. Fixes apache#40289

SUMMARY
Removes the
_mutate_labeloverride fromClickHouseConnectEngineSpecthat was appending hash suffixes to column aliases as a workaround for column name collision issues in older versions ofclickhouse-connect. This is no longer needed as ofclickhouse-connect>=0.13.0.Also bumps the minimum
clickhouse-connectversion to>=0.13.0across all locations includingpyproject.toml, engine spec metadata, and generated docs for consistency.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A
TESTING INSTRUCTIONS
N/A. This change removes a workaround that is no longer needed with modern versions of
clickhouse-connect. The base class_mutate_labelalready returns the label unchanged, so removing the override is a no-op in terms of behavior.ADDITIONAL INFORMATION