Repository navigation
Skip the JSON and Dynamic storage-layout functions in the AST fuzzer oracles - #126703
alexey-milovidov merged 2 commits into
Conversation
…oracles `JSONDynamicPaths`, `JSONDynamicPathsWithTypes`, `JSONSharedDataPaths`, `JSONSharedDataPathsWithTypes` and `isDynamicElementInSharedData` report where a value is stored (its own subcolumn or shared data), which is a property of the column, not of the value. The hash join emits a required right key as a copy of the left key (`copyLeftKeyColumnToRight`), so the same right key has a different layout below and above the join, and NoREC compared a filter pushed below the join with `countIf` evaluated above it (`AST fuzzer (amd_release, oracle)` on PR ClickHouse#120579). The engine does the same for `isConstant`, which the oracles already skip because it is not deterministic. Add the five names to the backstop set. Also make `namesNonDeterministicRegularFunction` consult that set for a name that resolves to a regular function: the bare-name screen (a function passed by name to a higher-order function, or a `{param:Identifier}` holding one) read only `isDeterministic()`, so set members such as `materialize` passed in `arrayMap(materialize, arr)` form. Gating the lookup on `FunctionFactory::tryGet` keeps columns named like a table or aggregate function in the set (`url`, `sum`) checked. Marking the five non-deterministic instead was rejected: a sorting or partition key using one of them, which is accepted today, would then be rejected, and an existing table keyed on one would stop loading. ClickHouse#117187 carries the same five entries inside a larger oracle refactor. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 0 findings) plus my own cold review (0 findings). Session id: cron:clickhouse-review-slot-10:20261019-123400 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-41:20261019-121700 |
|
cc @qoega @PedroTadim, could you review this and add the |
|
Workflow [PR], commit [5c55872] Summary: ✅
AI ReviewSummaryReviewed PR #126703 at Final VerdictStatus: ✅ Approve |
| "indexHint", | ||
| /// These report whether a `JSON` path or a `Dynamic` value has its own subcolumn or sits in shared data, | ||
| /// which depends on the column holding the value (a join or a merge can change it), not on the value. | ||
| "JSONDynamicPaths", "JSONDynamicPathsWithTypes", "JSONSharedDataPaths", "JSONSharedDataPathsWithTypes", |
There was a problem hiding this comment.
@groeneai are you sure no other functions are missing? There are many JSON functions
There was a problem hiding this comment.
I hadn't checked that exhaustively, so I did: every non-alias function in system.functions (about 1,700, scalar and aggregate, with up to two constant extra arguments) over rows holding the same JSON/Dynamic value stored both ways (own subcolumn or variant vs shared data). Apart from these five, the only deterministic function whose result differs is byteSize (52 vs 25 bytes for {"x":1}). It gives the same NoREC mismatch over this join on master (12 of 12 checked rounds), so I added it in 5c55872. blockSerializedSize and dumpColumnStructure differ as well, but they are already non-deterministic. The JSONExtract*, JSON_*, simpleJSON*, JSONAllPaths*, dynamicType and distinctJSONPaths* functions all return equal results.
| if (const auto resolver = FunctionFactory::instance().tryGet(name, context)) | ||
| if (!resolver->isDeterministic()) | ||
| if (!resolver->isDeterministic() | ||
| || nonDeterministicFunctionsLower().contains(Poco::toLower(name)) |
There was a problem hiding this comment.
@groeneai this is tricky, it could make deterministic functions labeled as non deterministic?
There was a problem hiding this comment.
Only inside the oracle. This helper feeds only hasNonDeterministicFunctions, whose sole use is to skip an oracle check, so a false positive costs one unchecked query, never a false mismatch. isDeterministic() and system.functions are unchanged.
For calls f(x) it changes nothing, because isOracleUnsafeFunctionName already looks the name up in this set. It makes the bare-name form arrayMap(materialize, arr) behave like arrayMap(x -> materialize(x), arr). Measured in system.functions (no aliases resolve to them), the names it newly screens are the five layout functions, byteSize, indexHint, initializeAggregation, materialize and throwIf; a column with one of those names also skips its query. The aggregate and table-function members (sum, url, ...) are not regular functions, so columns named like them stay checked.
`byteSize` of a `JSON` or `Dynamic` value counts the bytes of its in-memory representation, so it changes with the same storage layout (own subcolumn vs shared data) as the five functions added in the previous commit. Over the join from the original report, `WHERE byteSize(l.a) > 30` returns 20 rows with filter push-down and 0 with `query_plan_filter_push_down = 0`, and the oracle reported `Code: 906` in 12/12 and 11/13 checked rounds (call and bare-name form) on master; 0 with this change. A scan of every function in `system.functions` over rows holding identical `JSON`/`Dynamic` values in different layouts found no other deterministic function whose result changes (`blockSerializedSize` and `dumpColumnStructure` differ too, but are already non-deterministic). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units7 translation units recompiled, 11 s compile time in total, 7 of them have a recent master baseline. |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Stop the AST fuzzer oracles from reporting false mismatches on
JSONDynamicPaths,byteSizeand the other functions whose result depends on how aJSONorDynamicvalue is stored.Description
AST fuzzer (amd_release, oracle)failed on the unrelated #120579 with a NoREC mismatch(report):
... JOIN inner_json_shared AS l ON l.a = r.x WHERE NOT has(JSONDynamicPaths(l.a), 'x')returned 1 row, itscountIfform 0.JSONDynamicPaths,JSONDynamicPathsWithTypes,JSONSharedDataPaths,JSONSharedDataPathsWithTypesandisDynamicElementInSharedDatareport where a value is stored (its own subcolumn or shared data), not the value, andbyteSizemeasures that representation. The hash join returns a required right key rebuilt from the left key, sol.akeeps
xin shared data below the join and has it as a dynamic path above it: the filter pushed below the join andcountIfabove it are entitled to differ. Marking these non-deterministic instead would stop existing tables keyed onone from loading. No other deterministic function in
system.functionsdiffers for equal values stored both ways.The change, in
QueryOracleChecker.cpp:arrayMap(f, arr),{p:Identifier}) also consults that set for a name that resolves to aregular function. It read only
isDeterministic(), soarrayMap(materialize, [k])was checked.No query behaviour changes and no test, as in #125003. Oracle checks per 30 fuzzed rounds of each seed:
Code: 906JSON*Paths*functionisDynamicElementInSharedDatabyteSize, call /arrayMapformarrayMap(JSONDynamicPaths, ...)arrayMap(materialize, ...)JSONAllPaths, a column namedurl#117187 adds the five names inside a larger refactor, without
byteSizeor the bare-name change.Workflow [PR]
Sync PR [sync-upstream/pr/126703]
Version info
26.11.1.1055-master(included in26.11and later)