AST fuzzer oracle: run sub-queries with Dynamic JOIN keys disallowed #127078

Closed
groeneai opened 10:57pm on October 20, 2026 wanted to merge 0 ฮ” into clickhouse/clickhouse master from
oracle-no-dynamic-join-keys
Diff Delta:
0
Classified as:  General

groeneai's Description of Work

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):

Stop the AST fuzzer oracles from reporting false mismatches when a query compares a Dynamic column with a non-Dynamic one in a join.

Description

AST fuzzer (amd_release, oracle) failed on the unrelated #109071 with a TLP Aggregate mismatch
(report)
on SELECT count() FROM big__fuzz_9, small__fuzz_1 WHERE (bid = sid) AND (v = sid), after the fuzzer had changed
the columns to v Dynamic and sid UInt256.

The fuzzer profile sets allow_dynamic_type_in_join_keys = 1, and the oracle sub-queries inherited it. The WHERE p
arm of the TLP rewrite then turns v = sid into a hash-join key on CAST(sid AS Dynamic), where a UInt64 value never
equals a UInt256 one, so the arm returns 0. The reference and the not(p) / isNull(p) arms keep a cross join with
an equals filter, which matches 200 pairs. These are the "unexpected results" #86358 cites for forbidding Dynamic
JOIN keys by default.

The change pins the setting off in QueryOracleChecker::makeOracleContext, next to the other settings that make
rewrite forms disagree by design. This also covers a session SET compatibility = '25.9', which turns it on. The fuzzed
query itself still runs with the setting on, so crash fuzzing of Dynamic join keys is kept. An oracle sub-query with an
explicit Dynamic JOIN key now fails with ILLEGAL_COLUMN and is skipped.

No test, as in #125003. Code: 906 mismatches in 40 fuzzed rounds of the seed query on the fuzzed schema, clickhouse local:

arm
master
this PR

setting on, make_distributed_plan = 0
18/40
0/40

setting on, make_distributed_plan = 1
20/40
0/40

compatibility = '25.9'
21/40
0/40

control: setting off
0/40
0/40

With this PR the TLP Aggregate oracle still runs on these queries and passes.

๐Ÿค– Generated with Claude Code


Workflow [PR]
Sync PR [sync-upstream/pr/127078]
<!-- CI automatic block end :ci_links: -->

Version info


  • Merged into: 26.11.1.426-master (included in 26.11 and later)
    <!-- ch-version-info:end -->

1 total changed file
Loading changes...
Youโ€™ve reached the end
All files reviewed โ€” nice work, champ! ๐Ÿ’ช