Repository navigation
Add regression test for set index under MV layer type change (#89802) - #105552
PedroTadim merged 6 commits into
Conversation
…hange Closes ClickHouse#89802. When a `set` skip index is built on a non-`Nullable` storage column and the column is read through a MaterializedView declaring it `Nullable`, with `query_plan_merge_expressions = 0` keeping the MV's `_CAST` step separate from the WHERE filter, the index condition exception: Logical error: 'Unexpected return type from equals. Expected Nullable(UInt8). Got UInt8...' `MergeTreeIndexConditionSet` cloned the predicate verbatim, including `equals`' pre-resolved `result_type` resolved against the MV-layer `Nullable(Int32)` input. The granule block carries the storage column at the storage type (`Int32`), so `ExpressionActions::execute` runs `equals` on non-`Nullable` inputs (returning `UInt8`) but checks against the saved `Nullable(UInt8)` and throws. Fix: in `MergeTreeIndexConditionSet::atomFromDAG`, look up the granule (storage) type for each key column from `index_description.sample_block`, add an `INPUT` of that type, and `CAST` it back to the predicate's expected type. The downstream pre-resolved functions then see the type they were resolved for, keeping the function `result_type` invariant intact while the block fed into the actions remains the storage column unchanged. Added `tests/queries/0_stateless/04272_89802_set_index_mv_nullable_column_type.sql`. Verified the new test crashes the server without the fix and passes 30/30 runs with it; the existing 10 set-index stateless tests continue to pass.
|
Pre-PR validation gate (session
Local verification (debug build, master @
|
|
cc @rschu1ze @alexey-milovidov — could you review this? The fix is in |
|
Workflow [PR], commit [e6c136a] Summary: ✅ AI ReviewSummaryThis PR reduces Findings
Final Verdict
|
|
Bugfix validation FAIL update — investigated.
On master the test triggers a server crash (core dump captured), not a clean exception. Two options:
@PedroTadim @rschu1ze — which do you prefer? I'll push the PR-body edit either way. |
|
@groeneai I go with option 1 |
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered by tests: 19/22 (86.36%) | Lost baseline coverage: none · Uncovered code |
CI ledger — covered SHA:
|
| Check | Test | Disposition |
|---|---|---|
Stateless tests (amd_tsan, parallel, 1/2) |
00175_obfuscator_schema_inference |
flaky chronic trunk — task 2026-06-02-ci-00175obfuscatorschemainference-ab |
Unit tests (asan_ubsan) |
(check-level) | infra/chronic UBSan UntrackedMemoryCounter — task 2026-06-03-ci-p1-chronic-ubsan-in-untrackedmemoryc |
Bugfix validation (functional tests) |
04272_89802_set_index_mv_nullable_column_type |
this PR's OWN regression test — Bugfix validation framework limitation when MV layer type-change bug isn't reproducible on master HEAD without the right ordering. Not a real regression. |
No PR-caused failures. Awaiting human review.
Session: cron:our-pr-ci-monitor:20260604-213000
|
Going with option 1: category stays Bugfix validation FAIL is the framework limitation: server crashed (SERVER_DIED, captured core) instead of CI ledger for current HEAD |
CI finish ledger — c5346e6 (post master-merge)CI has fully finished (Finish Workflow passed; last checks 2026-06-24 13:14). This PR fixes a set-index LOGICAL_ERROR (MergeTreeIndexSet); the two TSan reds are an unrelated chronic trunk race. Every red check has an owner; only
The fix + regression test were AI-Review-approved; the only "failures" are the unrelated chronic TSan race (external fix #108391) and the maintainer-accepted Bugfix-validation framework artifact. Ready for review. Session id: cron:our-pr-ci-monitor:20260625-170000 |
|
@groeneai it seems the issue has been fixed. Can you update the PR with the test only to close the issue? |
…merge-tree-index-set-storage-type
Issue ClickHouse#89802 (LOGICAL_ERROR 'Unexpected return type from equals. Expected Nullable(UInt8). Got UInt8.' in MergeTreeIndexConditionSet under a MaterializedView layer Nullable type change with query_plan_merge_expressions=0) no longer reproduces on current master. Verified: the regression test 04272_89802_set_index_mv_nullable_column_type passes on pristine master HEAD without the MergeTreeIndexSet.{h,cpp} code change, so the code fix is reverted and the PR keeps only the test to lock the fixed behavior and close the issue. Related: ClickHouse#89802 Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
@PedroTadim confirmed: #89802 no longer reproduces on current master. I built pristine master HEAD (no code change) and the regression test |
| CREATE MATERIALIZED VIEW v_89802 TO t_89802 (c0 Nullable(Int)) AS (SELECT 1 c0); | ||
| INSERT INTO TABLE t_89802 (c0) VALUES (1), (2), (3), (10); | ||
|
|
||
| SELECT 'no_match', count() FROM v_89802 WHERE c0 = 0 SETTINGS query_plan_merge_expressions = 0; |
There was a problem hiding this comment.
This only asserts final counts, so it does not prove the set skip index path actually ran. If a future planner change stops applying skip indexes to MaterializedView reads, the original MergeTreeIndexConditionSet regression will stay green here because a full scan returns the same counts. Recent skip-index regressions pin use_skip_indexes_on_data_read = 0 / use_query_condition_cache = 0 or assert EXPLAIN indexes = 1 (03822_alias_column_skip_index_no_merge.sql, 04295_*, 04357_*) for exactly this reason. Please force or assert i0 usage in at least one query_plan_merge_expressions = 0 case.
CI finish ledger — ba107e5Test-only reduction (regression test for #89802; code fix reverted per @PedroTadim). Every failure below has an owner. All stateless shards that actually ran are green (0 test FAIL/ERROR in CIDB on this head).
The 4 DROPPED jobs are a transient praktika scheduler drop-cascade, not caused by this test-only change. Merged #109250 (tolerate missing profdata) is already on this branch but does not cover a fully-DROPPED coverage shard, so a fix task owns extending that tolerance. Session id: cron:our-pr-ci-monitor:20260709-150000 |
|
Correction to the 15:08 ledger. After full investigation the 4 reds are a transient GitHub Actions job cancellation, not a praktika scheduler drop-cascade, and there is no ClickHouse or praktika code bug to fix.
Remediation is a CI re-run of the cancelled jobs (needs repo admin on this fork PR), not a code change. No fixing PR; the drop-cascade fix task is closed as not actionable. Session id: cron:clickhouse-worker-slot-2:20260709-151000 |
Closes: #89802
Regression test only. The LOGICAL_ERROR from #89802 (
Unexpected return type from equals. Expected Nullable(UInt8). Got UInt8.inMergeTreeIndexConditionSet, hit through aMaterializedViewthat declares aset-indexed storage column asNullablewithquery_plan_merge_expressions = 0) no longer reproduces on current master. Verified:04272_89802_set_index_mv_nullable_column_typepasses on pristine master HEAD with no code change, so this PR drops the earlierMergeTreeIndexSet.{h,cpp}fix and keeps only the test to lock the fixed behavior and close the issue.Reproducer: https://fiddle.clickhouse.com/6dc1980e-30b2-4082-b570-5ef45287afc9
The test covers the original report plus matching,
AND/OR/NOT,IN (...), andUInt8-vs-Nullable(Int32)variants, under bothquery_plan_merge_expressionsvalues.Changelog category (leave one):
Version info
26.8.1.330(included in26.8and later)