Disable subcolumn function rewrites for Distributed by goutamadwant · Pull Request #108632 · ClickHouse/ClickHouse · GitHub
Skip to content

Disable subcolumn function rewrites for Distributed#108632

Open
goutamadwant wants to merge 2 commits into
ClickHouse:masterfrom
goutamadwant:fix-analyzer-distributed-subcolumns
Open

Disable subcolumn function rewrites for Distributed#108632
goutamadwant wants to merge 2 commits into
ClickHouse:masterfrom
goutamadwant:fix-analyzer-distributed-subcolumns

Conversation

@goutamadwant

Copy link
Copy Markdown
Contributor

Closes: #108299

Changelog category :

  • Bug Fix (user-visible misbehavior in an official stable release)

Changelog entry :

Fixed function-to-subcolumn optimization for Distributed tables when shard table schemas differ from Distributed table metadata.

Summary

  • Disabled function-to-subcolumn rewrites for Distributed storage because shard table schemas can differ from the Distributed table metadata.
  • Kept explicit subcolumn support for Distributed tables unchanged.
  • Added a stateless regression for a Distributed String column backed by a shard LowCardinality(String) column with optimize_functions_to_subcolumns.

Testing

  • git diff HEAD~1 HEAD --check
  • Could not run python3 tests/clickhouse-test 04365_distributed_optimize_functions_to_subcolumns --shard --no-random-settings --binary ./clickhouse: this checkout does not include a ./clickhouse binary.

@novikd novikd self-assigned this Jun 26, 2026
@novikd novikd added the can be tested Allows running workflows for external contributors label Jun 26, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Jun 26, 2026
bool supportsSubcolumns() const override { return true; }
/// The remote table schema can differ from the Distributed table schema,
/// so subcolumns inferred from local metadata may not exist on shards.
bool supportsOptimizationToSubcolumns() const override { return false; }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

supportsOptimizationToSubcolumns() is now correct on the bare Distributed storage, but the wrappers that can sit on top of it still inherit IStorage::supportsOptimizationToSubcolumns(), which falls back to supportsSubcolumns(). In particular, StorageProxy forwards only supportsSubcolumns() from getNested() ([src/Storages/StorageProxy.h:32]), and StorageMaterializedView does the same for getTargetTable() ([src/Storages/StorageMaterializedView.h:38]). That means a lazily loaded Distributed table or a materialized view over Distributed will still report true here and FunctionToSubcolumnsPass will keep rewriting name != '' into name.size != 0, so the same UNKNOWN_IDENTIFIER exception remains reachable through those entry points. Please forward supportsOptimizationToSubcolumns() through the wrappers as well, like StorageAlias already does.

@clickhouse-gh

clickhouse-gh Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.50% 85.40% -0.10%
Functions 92.60% 92.60% +0.00%
Branches 77.70% 77.60% -0.10%

Changed lines: Changed C/C++ lines covered: 5/5 (100.00%) · Uncovered code

Full report · Diff report

@novikd

novikd commented Jul 3, 2026

Copy link
Copy Markdown
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors pr-bugfix Pull request with bugfix, not backported by default

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Analyzer: UNKNOWN_IDENTIFIER error after optimize_functions_to_subcolumns applied to Distributed table

3 participants