Disable subcolumn function rewrites for Distributed#108632
Disable subcolumn function rewrites for Distributed#108632goutamadwant wants to merge 2 commits into
Conversation
| 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; } |
There was a problem hiding this comment.
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.
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 5/5 (100.00%) · Uncovered code |

Closes: #108299
Changelog category :
Changelog entry :
Fixed function-to-subcolumn optimization for Distributed tables when shard table schemas differ from Distributed table metadata.
Summary
Stringcolumn backed by a shardLowCardinality(String)column withoptimize_functions_to_subcolumns.Testing
git diff HEAD~1 HEAD --checkpython3 tests/clickhouse-test 04365_distributed_optimize_functions_to_subcolumns --shard --no-random-settings --binary ./clickhouse: this checkout does not include a./clickhousebinary.