Skip to content

Add runtime-filter Variant/Dynamic build-side regression tests - #108734

Merged
alexey-milovidov merged 3 commits into
ClickHouse:masterfrom
groeneai:groeneai/runtime-filter-variant-build-merge-coverage
Jul 14, 2026
Merged

alexey-milovidov merged 3 commits into
ClickHouse:masterfrom
groeneai:groeneai/runtime-filter-variant-build-merge-coverage

Conversation

@groeneai

@groeneai groeneai commented Jun 28, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #101415
Related: #106931

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

...

Description

Test-only. Extends 04327_runtime_filter_nested_variant with regression cases that exercise the join runtime-filter build side over Variant/Dynamic keys, complementing the existing cases which focus on the probe side (__applyFilter NULL handling, fixed in #106931 / #101415).

The exact-values runtime-filter Set is built incrementally: the first build block is adopted as the set element column via mutate, and every later block (plus every merged per-thread filter, ExactContainsRuntimeFilter::merge) goes through Set::appendSetElements -> IColumn::insertRangeFrom -> ColumnVariant::insertRangeFromImpl (and, for Dynamic, the "same variant_names" fast path in ColumnDynamic::insertRangeFrom). The original test only had one distinct build value per query, so this incremental insert/merge path was not covered.

The new cases force many tiny build blocks (max_block_size = 1) and parallel hash (max_threads = 8, join_algorithm = 'parallel_hash') over Variant(String, Bool), multi-alternative Dynamic, and Tuple(Dynamic, ...) keys, so build blocks whose local Variant discriminator order differs are inserted and merged. All cases pass on current master and are deterministic across repeated runs.

Version info

  • Merged into: 26.7.1.948 (included in 26.7 and later)

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? N/A (test-only coverage, not a fix for a reproduced crash). The reported OranjeAI sanitizer-stress signature (assertTypeEquality in ColumnVariant::insertRangeFromImpl via Set::appendSetElements) does NOT reproduce on current master after ~25 SQL shapes, 720-run randomized-settings stress, AST fuzzing, and distributed/remote paths. The column-level mechanism (guard at ColumnVariant.cpp checks variant count, not per-discriminator type) was confirmed via a throwaway gtest, but requires a non-canonical global discriminator scheme that no normal code path produces — the canonical-sorted-global invariant holds across CAST, ColumnDynamic::combineVariants, serialization, and distributed. The closely-related insertRangeFrom fast-path invariant facets were hardened on master in June (#107095 and siblings).
b Root cause explained? The original 04327 only exercised the runtime-filter PROBE side (one distinct build value per query). The crash signature is on the BUILD side: incremental Set::appendSetElements -> insertRangeFrom over Variant/Dynamic keys, and per-thread ExactContainsRuntimeFilter::merge. That path was untested.
c Fix matches root cause? This PR adds no code change; it adds regression coverage for the previously-untested build/merge path so future regressions in it are caught by 04327.
d Test intent preserved / new tests added? Existing 23 result lines unchanged (verified byte-identical); 4 new build-side cases added.
e Both directions demonstrated? All cases pass on current master with an exact .reference match and are deterministic across repeated runs. (No crashing direction exists on HEAD — see (a).)
f Fix is general across code paths? N/A (test-only, no code change).
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A (test-only, no code change).
h Backward compatible? (maintainer-approved exception only) N/A (test-only, no code change).
i Invariants and contracts preserved? N/A (test-only, no code change).

Session id: cron:clickhouse-worker-slot-0:20260628-093600

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @Avogar — could you review this? Test-only: it adds build-side regression coverage to 04327_runtime_filter_nested_variant for the join runtime-filter exact-values Set construction over Variant/Dynamic keys (the incremental Set::appendSetElements -> insertRangeFrom and per-thread ExactContainsRuntimeFilter::merge paths), which the original test (focused on the probe side, fixed in #106931) didn't exercise.

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Jun 28, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 28, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [7c471fc]

Summary: ✅


AI Review

Summary

This PR extends 04327_runtime_filter_nested_variant with build-side regression coverage for runtime-filter construction over Variant / Dynamic join keys, including the multi-stream ExactContainsRuntimeFilter::merge path. On the current head, the earlier coverage gaps are addressed: the test now forces incremental build blocks, uses numbers_mt for the merge case, and asserts the plan/pipeline so the intended runtime-filter build shape cannot disappear silently.

Final Verdict

✅ No new blockers or majors found in the current diff.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jun 28, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.30% 85.40% +0.10%
Functions 92.60% 92.60% +0.00%
Branches 77.50% 77.60% +0.10%

Changed lines: No C/C++ source files changed — skipping uncovered code analysis.

Newly covered by added/modified tests: 304 line(s), 46 function(s) across 113 file(s) · Details

Top files
  • src/Storages/StorageReplicatedMergeTree.cpp: 23 line(s)
  • src/AggregateFunctions/AggregateFunctionIntervalLengthSum.cpp: 18 line(s), 40 function(s)
  • src/Common/ZooKeeper/ZooKeeperImpl.cpp: 17 line(s)
  • src/Functions/FunctionsBitmap.h: 12 line(s)
  • src/Storages/MergeTree/ReplicatedMergeTreeQueue.cpp: 12 line(s)

Full report

@cv4g cv4g self-assigned this Jun 29, 2026
@groeneai
groeneai force-pushed the groeneai/runtime-filter-variant-build-merge-coverage branch from 0b19c36 to 57de2db Compare June 29, 2026 15:52
Extends 04327_runtime_filter_nested_variant with cases that exercise the
runtime-filter build side, not just the probe side. The exact-values Set is
built incrementally, so each build block after the first goes through
Set::appendSetElements -> ColumnVariant / ColumnDynamic insertRangeFrom, and
each per-thread filter is combined via ExactContainsRuntimeFilter::merge.

The insert path is exercised with numbers() cast to Variant/Dynamic and a
small max_block_size so the build side emits many tiny blocks (format()
reparses its whole input into one block, so it never hit the incremental
path). The merge path needs several parallel build streams: numbers() is
forced to a single stream, so BuildRuntimeFilterStep captures one build
stream (filters_to_merge = 0) and merge() never runs. The parallel-hash case
therefore uses numbers_mt(), which fans the build side across max_threads
streams so multiple BuildRuntimeFilterTransform instances are merged.
query_plan_join_swap_table = false keeps the right table the build side.
count() is invariant to join order and block size.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@groeneai
groeneai force-pushed the groeneai/runtime-filter-variant-build-merge-coverage branch from 57de2db to 169355a Compare June 29, 2026 16:39
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger — 169355a

CI finished on this head (Finish Workflow: success). This is a test-only PR (diff: 04327_runtime_filter_nested_variant.{sql,reference} only). The gating Fast test failed on an unrelated flaky test, which left the rest of the pipeline skipped.

Check / test Reason Owner / fixing PR
Fast test / 02669_alter_modify_to_nullable flaky mutation-visibility race, unrelated to this PR's diff (0 master / 4 unrelated PRs / 14d; part metadata reads post-mutation state too early) a fix task is created (investigating at full effort — fixing-PR link to follow on this PR)

No PR-caused failure: 02669_alter_modify_to_nullable is an ALTER-MODIFY-to-Nullable mutation test, entirely unrelated to this PR's runtime-filter Variant/Dynamic test change. A Fast test re-run clears it.

Session id: cron:our-pr-ci-monitor:20260629-170000

@groeneai

Copy link
Copy Markdown
Collaborator Author

Investigated the 02669_alter_modify_to_nullable Fast-test flake from the ledger above. Confirmed it is unrelated to this PR's diff and never fails on master (0 master / 6 distinct unrelated PRs / 90d). Root cause: the ALTER MODIFY -> Nullable metadata-only optimization falls back to a full part rewrite when the mutation is not isolated; data results stay correct, only the per-part read_rows assertion flips. Filed #108845 with the full analysis and a proposed fix. Fixing PR link will be posted here once opened.

@groeneai

groeneai commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator Author

Fixing PR for the flaky 02669_alter_modify_to_nullable CI-finish-ledger line created: #109205

@groeneai

groeneai commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger — 169355a

CI fully finished (Finish Workflow pass). This PR adds only 04327_runtime_filter_nested_variant.sql; the sole failure is an unrelated chronic flaky test.

Check / test Reason Owner / fixing PR
Fast test / 02669_alter_modify_to_nullable flaky (chronic: fails across many unrelated PRs — 96130, 106586, 106734, 108055, 108217, 108584; this PR does not touch 02669) #109205 (ours, open)

Session id: cron:our-pr-ci-monitor:20260703-053000

@groeneai

Copy link
Copy Markdown
Collaborator Author

Update on the 02669_alter_modify_to_nullable ledger line: PR #109205 (retry rewrite) was closed unmerged. Deeper analysis (on #109205) showed the signature is a canary for a real, time-clustered metadata/commands drift, not a constant-rate flake, so rewriting the test to retry would mask what it exists to catch. The underlying drift was fixed upstream by #104822 (merged 2026-07-03); the fail-open path is now observable via #110157. The flake is gone from master (0 occurrences before 2026-06-09 / after ~2026-07-01), so there is nothing to change in the test. Issue #108845 closed as resolved.

The four build-side cases asserted only count(), so they would stay green
even if the planner stopped building or applying the runtime filter for
this shape. Add a plan/pipeline assertion to each: EXPLAIN actions = 1 must
contain a BuildRuntimeFilter action, and the numbers_mt merge case must show
multiple BuildRuntimeFilterTransform instances (proving filters_to_merge > 0
so ExactContainsRuntimeFilter::merge runs). The assertions pin
enable_join_runtime_filters = 1 so the CI randomizer cannot disable the
filter under them.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger — 7c471fc

Every failure below has an owner: a fixing PR (ours or external), or a full-effort fix task whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
CH Inc sync — CH Inc sync (private, not actionable by us)

All other checks pass on this head (Style check pass, both Stateless tests (amd_llvm_coverage, AsyncInsert, s3 storage) lanes pass, Finish Workflow + Mergeable Check pass; the remainder skipped by the test-only pipeline gate). This is a test-only PR (tests/queries/0_stateless/04327_runtime_filter_nested_variant.{sql,reference}); the added plan/profile assertions (EXPLAIN actions=1 / EXPLAIN PIPELINE for the numbers_mt merge case, per the 2026-07-14 review) are present and green.

Session id: cron:our-pr-ci-monitor:20260714-163000

@alexey-milovidov
alexey-milovidov merged commit 862617d into ClickHouse:master Jul 14, 2026
175 of 176 checks passed
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 14, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…ilter-variant-build-merge-coverage

Add runtime-filter Variant/Dynamic build-side regression tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants