Repository navigation
Revert "Fix false AST fuzzer oracle mismatch on approx_top_k" - #119957
Conversation
|
Workflow [PR], commit [68ced1a] Summary: ⏳
AI ReviewSummaryThis PR reverts the Findings
Final VerdictChanges requested. This trades one flaky test for the broader production regression that |
| /// names they are registered under and are equally valid in a query. | ||
| "any_respect_nulls", "anyLast_respect_nulls", | ||
| "first_value", "last_value", | ||
| "topK", "topKWeighted", |
There was a problem hiding this comment.
Reverting these entries reopens the exact TLP Aggregate mismatch that #118489 fixed. QueryFuzzer::swapAggregateNames() still substitutes approx_top_k / approx_top_sum directly, while checkTLPAggregate() only rejects the names listed here plus the smaller non-associative subset later in the function. With these names gone from the unsafe set, queries like SELECT g, approx_top_k(v) ... GROUP BY g are treated as oracle-safe again even though the bounded counter table is merge-order dependent, so CI will start reporting the old false mismatches again. A narrower revert that only drops or rewrites the flaky test would avoid reintroducing the production gap.
| { | ||
| while (true) | ||
| { | ||
| if (non_deterministic_functions_lower.contains(Poco::toLower(name))) |
There was a problem hiding this comment.
Dropping alias expansion here reopens the alias spellings that scanAggregatesSafe() still accepts as aggregates. AggregateFunctionFactory::isAggregateFunctionName() is alias-aware and strips combinators, so approx_top_count, min_byOrNull, array_concat_agg, anova, STDDEV_POP, etc. still reach checkTLPAggregate(), but this guard now only tests the raw spelling against the local denylist. That lets order-sensitive aliases of approx_top_k, argMin, groupArray, analysisOfVariance, and similar aggregates back through the oracle and recreates the false-mismatch class that 05141_oracle_skips_aggregate_aliases was covering.
Re-land of ClickHouse#118489, which was reverted by ClickHouse#119957 because its test 05141_oracle_skips_aggregate_aliases was flaky. The revert reason was the test, never the deny-list logic, so master is exposed to the false mismatch again: five occurrences of "AST Fuzzer oracle mismatch: TLP Aggregate" naming approx_top_k since 2026-09-14, two of them on master itself. QueryOracleChecker compares a query's result against a metamorphic rewrite for exact row equality, so it keeps a backstop set of aggregates whose State/Merge path legitimately diverges from direct evaluation. topK and topKWeighted were listed; their space-saving counterparts approx_top_k and approx_top_sum were not, even though QueryFuzzer's aggregate swap list offers approx_top_k for any single-argument aggregate. Which elements survive the bounded counter table, and the counts reported for them, depend on the order values arrive in and on how the partial states merge, so the partitioned rewrite is entitled to disagree with the whole-table reference. Aliases are resolved through AggregateFunctionFactory::getAliasToOrName rather than enumerated, because listing each spelling by hand rots silently and one missing spelling is one false mismatch. Two things differ from ClickHouse#118489. First, the 05141 flake is fixed at its cause. probe() runs the probe query once unfuzzed with the oracle off, purely to read the client's exit status and so tell "this unsafe spelling was skipped" from "this spelling is broken". That invocation redirected nothing, so any server error on it reached the test's stderr, and clickhouse-test fails a test with non-empty stderr regardless of stdout. Exactly one probed aggregate was partial: AnalysisOfVarianceMoments::getFStatistic() throws BAD_ARGUMENTS "There is only one observation in each group" when k == n, which the empty input satisfies with k = n = 0. A degenerate read of the fixture therefore turned the anova gate into a leaked <Error> and failed the test. Both recorded instances are that chain, both identifiable as the unfuzzed gate query by their "(query 1, line 2)" position. The gate's stderr is now discarded, in 05140 as well as 05141, since the two files carry the same probe(). What made the fixture read degenerate is not established, and the fix deliberately does not depend on knowing: a probe's validity gate must not depend on an aggregate's runtime data preconditions. Measured with the fixture INSERT reduced to numbers(0), the pre-revert test reproduces "Reason: having stderror" while this version passes with an empty stderr. The anova probe is dropped rather than repaired because it is the only partial aggregate in the list, and its mechanism class, a raw case-sensitive alias of a deny-listed aggregate, is covered identically by min_by, array_agg, array_concat_agg and medianTDigest. Keeping it would have meant either a UNION ALL shape the oracle is likely to reject outright, which makes the probe vacuous, or a row-count assertion that re-reds the test on the very event the dependence is being removed from. Second, ClickHouse#118489 also removed quantileDeterministic and quantilesDeterministic from the set and added a medianDeterministic(v, 1) positive control that depends on their absence. That measurement does not hold: in the same amd_tsan job as the 05141 failure, master recorded a TLP Aggregate mismatch on "SELECT medianDeterministic(v, 1) FROM oracle_alias_agg", and oracle_alias_agg is 05141's own fixture, so the test was generating master oracle mismatches through its own positive control. Those two entries are left as master has them today. The re-landed alias resolution then rejects every median* spelling of a listed quantile* family, which also makes that control mechanically impossible, so it is removed with the de-listing. The over-rejection risk it covered is already covered by the "safe aliases" control (Bit_And, BIT_OROrNull, BIT_XOR resolving to the associative and commutative groupBitAnd, groupBitOr and groupBitXor), which exercises the raw, combinator-suffixed and mixed-case alias shapes and must stay checkable.
Reverts #118489
Makes CI flaky:
Workflow [PR]
Sync PR [sync-upstream/pr/119957]
Version info
26.9.1.1468(included in26.9and later)