Repository navigation
Allow duplicate inputs when evaluating the Merge table-selection filter - #117612
Conversation
…n inputs
The `Merge` engine decides which tables to read by evaluating the part of the
filter that depends only on `_database` and `_table` over a one-row block
holding exactly those two columns. An `indexHint` argument contributes a
second input for the same virtual column, and a block holding it once cannot
satisfy both, so the query failed instead of narrowing the read:
SELECT _table, key FROM m_all
WHERE indexHint(_table = 'm_v1') AND (_table = 'm_v1');
-- Code: 10. Not found column _table in block:
-- while executing 'INPUT : 1 -> _table LowCardinality(String) : 3'
`indexHint` may only narrow which data is read, never fail the query, and the
bare predicate worked. The block is now built from the expression's required
columns, so it provides each input as many times as the expression asks for
it.
Closes: #114013
|
Workflow [PR], commit [86bfcd4] Summary: ❌
AI ReviewSummaryThis PR fixes Final Verdict✅ No new findings on the current diff. Residual risk: I did not run the new stateless test locally in this review, so this verdict is based on code inspection and the added regression coverage. LLVM Coverage ReportMeasured on commit 86bfcd4.
Changed lines: Changed C/C++ lines covered: 4/4 (100.00%) · Uncovered code |
|
There is a zero-input edge in the new block construction that turns a fail-loud case into a silently empty result. The new block is built from Zero-input split DAGs are reachable at default settings: the A small guard closes it: if |
Build profile diff (arm_release)Comparing commit See the job log for details. |
Building the block from the expression's own inputs is wrong for a split
predicate that needs no input at all. `indexHint(materialize(1))` produces a
constant-only DAG, so `getRequiredColumnsWithTypes` is empty, the block has zero
columns, and `ExpressionActions::execute` therefore derives `num_rows = 0` and
evaluates every action over zero rows. The `getBool(0)` that decides table
selection then reads past the end of an empty column - landing in the static
zero-initialized `empty_pod_array`, so no sanitizer notices - and returns false,
which prunes every child table and silently returns an empty result.
Measured against a local build of the previous commit, with two `MergeTree`
tables of one row each behind a `Merge` table:
SELECT count() FROM m_all WHERE indexHint(materialize(1)) -- 0, master gives 2
SELECT count() FROM m_all WHERE indexHint(materialize(1)) AND key >= 1 -- 0, master gives 2
Restore the fixed one-row `_database` / `_table` block and pass
`allow_duplicates_in_input = true` instead. That binds every duplicate input to
the same block column - they all carry the same value - and keeps the one-row
invariant the `getBool` relies on. It is also what `filterBlockWithExpression`,
every other consumer of these split predicates, already does.
Cover the constant-only shapes in the test.
Address review: #117612 (comment)
…an fire `apt-get update` does not treat a failed repository index fetch as fatal: it reports the failure at `W:` severity, exits 0, and proceeds with a stale or absent index. The `RUN` chain therefore continues into `apt-get install`, which resolves against an index that was never refreshed and dies at `E:` severity with `E: Unable to correct problems, you have held broken packages`, preceded by `wget : Depends: libpsl5 (>= 0.16.0) but it is not installable`. Everything downstream then behaves correctly on the evidence it is handed. buildx fences the tail of the failing step, which by then holds only the resolution error; `terminal_build_failure` returns that fence; `is_apt_mirror_failure` finds no `APT_MIRROR_ERRORS` token at `E:` severity, because the lines that do carry those tokens are `W:` and sit above the fence; `should_try_next_mirror` returns False and the mirror loop exits without ever rebuilding against Canonical. The Canonical fallback is therefore handed exactly the evidence it is designed to reject, on the outage it exists for. `--error-on=any` promotes those lines to `E:` and stops the chain before the install runs, which is the shape the merged classifier was written to recognise. Nothing in `ci/` changes. Measured in `ubuntu:22.04` (apt 2.4.14), against a local 503 server and against a refused port: failure shape apt-get update rc severity of the mirror lines 503 on InRelease plain 0 W: 503 on InRelease --error-on=any 100 E: connection refused plain 0 W: connection refused --error-on=any 100 E: `any` is apt's only accepted value; `no`, `some` and `warn` each return `E: Unknown update error mode`. End to end, with each captured buildx output fed to the shipped `should_try_next_mirror`: docker/server/Dockerfile.distroless 503 False -> True docker/keeper/Dockerfile.distroless 503 False -> True docker/server/Dockerfile.ubuntu 503 False -> True docker/server/Dockerfile.distroless connection refused False -> True The pristine tree reproduces the CI failure byte-for-byte: same failure point (`Dockerfile.distroless:31`), same `exit code: 100`, same unmet dependency, same terminal error. Both arms still fail the build, so this changes the classification, not the outcome of a broken mirror. Control: a full `ch-builder` build against the real mirrors still succeeds with rc 0 and zero `E:` lines, exercising all three flagged sites including the `packages.clickhouse.com` refresh. The repository already documents this defect on the sibling package manager, in `docker/server/Dockerfile.alpine` and `docker/keeper/Dockerfile`: "`apk` has no retry option, and it does not treat a failed repository index fetch as fatal: it proceeds with an empty index, so every requested package is then reported as `no such package`". apt behaves the same way and, unlike apk, has an option for it. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=117612&sha=641c9b6831e3c49cc505ac66eed049c46b1f4a4d&name_0=PR&name_1=Docker%20server%20image Related: ClickHouse#117612 Related: ClickHouse#116444 Co-Authored-By: Claude Opus 5 <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Fixed
NOT_FOUND_COLUMN_IN_BLOCKwhen a predicate on aMergetable's_tableor_databasevirtual column is wrapped inindexHint.Documentation entry for user-facing changes
The
Mergeengine decides which tables to read by evaluating the part of the filter that depends only on_databaseand_tableover a one-row block holding exactly those two columns. AnindexHintargument contributes a second input for the same virtual column, and the expression was executed without allowing duplicate inputs, so the second input found nothing in the block and the query failed instead of narrowing the read:indexHintmay only narrow which data is read, never fail the query, and the bare predicate worked. Duplicate inputs are now bound to the same block column - they all carry the same value - which is whatfilterBlockWithExpression, every other consumer of these split predicates, already does.Closes: #114013
Workflow [PR]
Sync PR [sync-upstream/pr/117612]
Version info
26.10.1.302-master(included in26.10and later)