Repository navigation
Fix insert-select from delta lake cluster with replicated merge tree - #101299
Conversation
|
Workflow [PR], commit [0bd16fa] Summary: ❌
AI ReviewSummaryThis PR updates Missing context
Findings❌ Blockers
Tests
ClickHouse Rules
Final Verdict
|
| nodes_to_process.insert(nodes_to_process.end(), node->children.begin(), node->children.end()); | ||
|
|
||
| if (auto * with_filter = dynamic_cast<SourceStepWithFilter *>(node->step.get())) | ||
| return with_filter->detachFilterActionsDAG() |
There was a problem hiding this comment.
This line is missing a trailing ;, so the file does not compile.
Suggested fix:
- return with_filter->detachFilterActionsDAG()
+ return with_filter->detachFilterActionsDAG();| INSERT INTO {table_name}_dst (event_time, account_id, impressions) | ||
| SELECT event_time, account_id, impressions | ||
| FROM {table_function} | ||
| WHERE (event_time >= '2026-02-01') AND (event_time < '2026-02-02') |
There was a problem hiding this comment.
This test validates simple partition pruning, but it does not cover the multi-source shape (WHERE scalar subquery) that adds another source step in the plan.
Please add a case like:
INSERT INTO ...
SELECT ...
FROM deltaLakeCluster(...)
WHERE event_time = '2026-02-01'
AND (SELECT count() FROM system.one) = 1Without this, the regression around selecting the wrong SourceStepWithFilter remains untested.
| else if (select_query->where()) | ||
| condition_ast = select_query->where()->clone(); | ||
|
|
||
| if (condition_ast) |
There was a problem hiding this comment.
The new pruning path now builds a filter DAG directly from prewhere/where and forwards any analysis exception to the caller. Because this optimization is optional, this can turn valid INSERT ... SELECT queries into exceptions (for example, predicates that are valid for normal execution but not representable in this isolated filter-analysis pass).
Please treat filter extraction here as best-effort: if DAG construction fails, log at debug/trace and continue with predicate = nullptr / filter_actions_dag = nullptr so the query still executes without pruning.
|
Issue about virtual columns here: #101515 |
| filter_dag = ExpressionAnalyzer(condition_ast, syntax, local_context).getActionsDAG(true, true); | ||
| predicate = filter_dag->getOutputs().at(0); | ||
| } | ||
| catch (...) |
There was a problem hiding this comment.
Catching all exceptions here and silently continuing can swallow cancellation-like exceptions (QUERY_WAS_CANCELLED, timeout/resource-limit exceptions) and proceed with remote execution even though the query should stop.
This optimization should stay best-effort for analysis failures, but cancellation/interrupt exceptions should be rethrown. Please narrow the catch or explicitly rethrow cancellation exceptions before falling back to nullptr predicate.
…ith replicated merge tree
…ith replicated merge tree
Backport #101299 to 26.2: Fix insert-select from delta lake cluster with replicated merge tree
Backport #101299 to 26.3: Fix insert-select from delta lake cluster with replicated merge tree
…ith replicated merge tree
`INSERT INTO <replicated table> SELECT ... FROM <cluster table function>` with
`parallel_distributed_insert_select` distributes the read tasks from the
initiator, and the initiator prunes the object list with the `WHERE`/`PREWHERE`
condition of the `SELECT`.
That condition is analyzed on its own, out of the context of the query, so
aliases introduced in the `WITH` clause or in the `SELECT` list were not
resolvable. A perfectly normal query such as
INSERT INTO wikistat
WITH splitByChar(' ', line) AS values
SELECT ...
FROM s3Cluster(default, 'https://.../pageviews-*.gz', 'LineAsString')
WHERE length(values) >= 3
failed the analysis with `UNKNOWN_IDENTIFIER`, which disabled the pruning and,
worse, wrote an `<Error>` message with a full stack trace into the server log.
Substitute the aliases on a copy of the `SELECT` before extracting the
condition, the same way the regular query analysis does. The condition above
becomes `length(splitByChar(' ', line)) >= 3`, which analyzes fine, so the
pruning now works for aliased conditions and nothing is logged.
The analysis is still best-effort - a condition that cannot be analyzed in
isolation (for example, one that qualifies columns with the table alias) falls
back to no pruning, which is correct, just slower. That is an expected outcome
rather than an error, so it is logged at the `debug` level now.
Related: ClickHouse#101299
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix insert-select from delta lake cluster with replicated merge tree
Documentation entry for user-facing changes
Version info
26.4.1.50626.3.5.7,26.2.8.12