Repository navigation
Send the filter on a table read by a cluster function to the replicas - #125615
Conversation
In a query with several tables, the replicas of a cluster function read the whole table and sent all rows to the initiator, which applied the filter only after receiving them. The initiator now serializes the deterministic conjuncts of the filter over the read columns as an `ActionsDAG`, together with the ready sets of `IN`, and sends it in the internal setting `cluster_table_function_pushed_down_filter`. The replicas add it as a `FilterStep` after reading. The initiator still applies the whole filter. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Workflow [PR], commit [92f0153] Summary: ✅
AI ReviewSummaryThe PR sends eligible object-storage cluster-function filters to replicas to reduce transferred rows. Four previously reported concerns remain at head PR Metadata
Missing context / blind spots
Findings❌ Blockers
💡 Nits
Tests
Final Verdict❌ Block. Preserve valid-query execution for compiled lambdas and deterministic UDFs, enforce the decoding limit on both payload components, and address or explicitly narrow the ready-subquery-set contract. Add the focused regression evidence and complete the changelog entry. |
The secondary queries of a cluster function run in the `default` database, so they are tied to the test through their initial query, which runs in the current database. Fixes the style check. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=125615&sha=797c0c9e561db8719d6261bf06aeea479f53835a&name_0=PR&name_1=Style%20check PR: #125615 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Iceberg tables no longer accept `UInt64` columns, so `CREATE TABLE` failed and the test did not run at all. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=125615&sha=d30c47c13c1f6f1557f64c48107760172410f609&name_0=PR Related: #125615 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…pt built subquery sets Only `StorageObjectStorage` applies `cluster_table_function_pushed_down_filter` on the replicas, so do not serialize it for `fileCluster` and `urlCluster`. Also accept `IN (subquery)` sets that are already built with explicit elements: `serializeReadySets` ships them as values. Sets from `Set` tables are still not shipped, because the replicas of a cluster function do not necessarily have the table. Co-Authored-By: Claude Opus 5.5 <[email protected]>
With a randomized `max_insert_threads` > 1, the `INSERT SELECT` into the `IcebergLocal` table runs several sinks, each committing its own snapshot. They conflict on `vN.metadata.json`, the loser retries, and `writeMetadataFile` logs the conflict at `<Error>`, which fails the test because of stderr. The result is correct. The test is about the filter pushdown, so insert with a single thread. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=125615&sha=b63ba4600a9e2d1d280b641f8de91588e480dcaa&name_0=PR PR: #125615 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…lter-pushdown-to-replicas # Conflicts: # src/Storages/ObjectStorage/StorageObjectStorage.h
…he settings history CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=125615&sha=7e5f7bf226c456a92b6e50437e71f42d47f95046&name_0=PR&name_1=Style%20check PR: #125615 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes7 object files changed (+80.12 KiB total), 0 added.
719 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units393 translation units recompiled, 3583 s compile time in total, 393 of them have a recent master baseline. |
|
@scanhex12 do you think we need to report this Altinity#2602 upstream or this PR addresses the same issue ? |
…n-through-rename Resolve the conflict in `IStorageCluster.cpp`: master (ClickHouse#125615) added serialization of the filter for replicas in `ReadFromCluster::applyFilters`, while this branch removed `applyFilters` and builds the task iterator extension once in `initializePipeline`. Keep `applyFilters` only to compute `pushed_down_filter`, and keep creating the extension in `initializePipeline`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tting-improvements Most of this branch landed through separate PRs: #125611 #125615 #125636 Their versions are kept. Bucket splitting by `min_buckets` is applied on top of the greedy splitter of master, the weight of a byte range bucket is capped by the file size, byte ranges are gated by `cluster_table_function_split_by_split_offsets`, and the duplicate test of the filter pushdown is removed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tion Since ClickHouse#125615, ReadFromCluster::applyFilters serializes the filter conjuncts that isSerializableFilterNode accepts into cluster_table_function_pushed_down_filter, and each replica rebuilds them with ActionsDAG::deserialize. The gatekeeper also accepted lambda carriers: a constant-folded lambda (ColumnConst(ColumnFunction)) and a capturing lambda (FunctionCapture). A lambda body is an ExpressionActions built while the initiator plans the query, and its constructor JIT-compiles the DAG in place, replacing the nodes with an LLVMFunction named after CompileDAG::dump(). The serialized filter then carries that name, and the replica's FunctionFactory::get throws UNKNOWN_FUNCTION once the body has been compiled (after min_count_to_compile_expression runs). The planner keeps lambda bodies uncompiled only for plans that are shipped as a whole (ClickHouse#119332, mayBeSerializedForRemoteExecution). This plan is executed on the initiator, so refuse Function-typed nodes in the gatekeeper instead. The check runs before the recursion, so the whole atom stays on the initiator and the other conjuncts are still sent. The initiator applies the full filter, so results do not change; the replicas only stop pre-filtering by lambda conjuncts, as before ClickHouse#125615. Extend 05394_cluster_function_filter_pushdown_to_replicas with a folded and a capturing lambda case. Closes ClickHouse#128422 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…able function `ReadFromCluster::applyFilters` (added by ClickHouse#125615) renames the inputs of the filter it sends to the replicas (`cluster_table_function_pushed_down_filter`) by pairing output-header column `i` with select expression `i` of the query sent to them. The initiator reads a `*Cluster` function at `WithMergeableState`, and for an aggregation the header there is the GROUP BY keys followed by the aggregate states, not the select list. A key predicate pushed through `MergingAggregated` (HAVING, or an outer WHERE over the aggregation) was therefore renamed onto another column: in `SELECT b, a + 0 AS x, count() ... GROUP BY x, b HAVING x = 2` the replicas got `b = 2`, filtered the rows of the group `x = 2` out before aggregating, and the query returned nothing. Build the filter only when the header is the select list: `WithMergeableState` with no aggregation and no window functions, the condition under which the planner's first stage ends with the projection (the same one `StorageMerge` uses). The initiator applies the whole filter anyway; the replicas no longer pre-filter an aggregation by a key predicate, which is the behaviour before ClickHouse#125615. The JOIN case ClickHouse#125615 targets is planned as a projection and keeps its pre-filtering (05394 still checks that the replicas get the filter there). The name map keys a column by its own name instead of its select alias: the filter inputs of the read are renamed to the storage names, so an alias that is the name of another column (`SELECT a AS b, t.b AS c`) mapped a filter on `t.b` onto `a`. Closes ClickHouse#128421 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-serialized-plan Conflicts: `ProtocolDefines.h` (both sides' version 21 entries kept; plan version stays 21, the 26.11 value), `ActionsDAG.cpp` (master's post-order node walk and `isConstantValueInCacheKey`, with the `IndexHintActions` parameter), `SelectQueryInfo.h` (master's `QueryPlanStepSerialization` spelling). Two new call sites of `ActionsDAG::serialize` on master need the parameter: the filter that `ReadFromCluster` sends to the replicas of a cluster table function (ClickHouse#125615) writes the predicate of `indexHint` (the replica rebuilds the filter with the same release), and the ActionsDAG deserialization gtest refuses it (the DAG has no `indexHint`). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…able function The filter that a cluster table function sends to its replicas (ClickHouse#125615) is built from the conjuncts that `isSerializableFilterNode` accepts. That check walks the children of a node, but the predicate of `indexHint` is a separate DAG it does not walk. Writing the predicate there made a query fail that works on master: SELECT count() FROM icebergLocalCluster(...) AS t, (SELECT number AS k FROM numbers(1000)) AS n WHERE t.a = n.k AND t.a % 2 = 0 AND indexHint(t.a IN (SELECT number FROM numbers(10))) -- Code: 344. Cannot ship an IN-subquery set to distributed-plan worker tasks (the set is not built) On rows `indexHint` is always true, so before this PR the replicas got a hint rebuilt without its predicate that filtered nothing. Leaving the conjunct out keeps the rows each replica sends unchanged, and the filter is now serialized with `Refuse`, so a hint that reaches it fails instead of being dropped. Co-Authored-By: Claude Opus 5.5 <[email protected]>
In a query with several tables, the replicas of a cluster function read the whole table and sent all rows to the initiator, which applied the filter only after receiving them. The initiator now serializes the deterministic conjuncts of the filter over the read columns as an
ActionsDAG, together with the ready sets ofIN, and sends it in the internal settingcluster_table_function_pushed_down_filter. The replicas add it as aFilterStepafter reading. The initiator still applies the whole filter.Part 3: #124890
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Workflow [PR]
Sync PR [sync-upstream/pr/125615]
Version info
26.11.1.979-master(included in26.11and later)