Repository navigation
Fix assertion failure in AggregateFunctionArray with parametric Nothing functions - #100679
Conversation
…ng functions AggregateFunctionNothingImpl constructor was discarding all parameters by explicitly passing Array() to the base class. When the Null combinator created a NothingNull function with parameters (e.g. quantile(0.5) resolved with Nullable(Nothing) arguments), these parameters were lost. Outer combinator wrappers like Array then received the original parameters but nested_func->getParameters() returned empty, causing the assertion `parameters == nested_func->getParameters()` to fail. The fix preserves parameters through AggregateFunctionNothingImpl (they are stored but not functionally used) and passes them consistently in the factory's combinator wrapper path. Closes ClickHouse#100584 Co-Authored-By: Claude Opus 4.6 <[email protected]>
|
Workflow [PR], commit [ec89372] Summary: ✅ AI ReviewSummaryThis PR fixes an assertion exception in aggregate combinator chains involving parametric functions over all- ClickHouse Rules
Final Verdict
|
…ation Update 03318_ubsan_resample_arguments_count to expect ILLEGAL_TYPE_OF_ARGUMENT instead of NUMBER_OF_ARGUMENTS_DOESNT_MATCH. The old error was an artifact of AggregateFunctionNothing dropping parameters — now that parameters are preserved, the Resample combinator validates successfully and the real error (Merge suffix receiving Nullable(Nothing) instead of AggregateFunction) is reported. Add type-name check to regression test to demonstrate the fix on release builds (assertions only fire in debug mode, so bugfix validation needs this).
LLVM Coverage Report
PR changed lines: PR changed-lines coverage: 100.00% (12/12, 0 noise lines excluded) |
|
cc @rschu1ze @alexey-milovidov — could you review this? It fixes an assertion failure in AggregateFunctionArray when used with parametric Nothing functions. |
alexey-milovidov
left a comment
There was a problem hiding this comment.
Yes, the fix is correct. Thank you!
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Fix server crash (assertion failure) when using parametric aggregate functions with Array combinator and NULL arguments, such as
quantileIfArrayArray(0.5)([[NULL]], [[1]]).What this PR does
Fixes #100584 — assertion
parameters == nested_func->getParameters()failure inAggregateFunctionArrayconstructor, triggered by the AST fuzzer.Root cause:
AggregateFunctionNothingImplconstructor explicitly discarded all parameters by passingArray()to the base class (line 52 inAggregateFunctionNothing.h). When the Null combinator resolved a parametric function likequantile(0.5)with only-NULL arguments, it createdAggregateFunctionNothingNullwith the original parameters[0.5]— but those parameters were silently dropped by the constructor.When an outer combinator (like
Array) then wrapped this Nothing function, it passed the original parameters to its own wrapper, butnested_func->getParameters()returned empty — triggering the assertion.Fix:
AggregateFunctionNothing.h: Preserve parameters through the constructor instead of discarding them. The Nothing functions don't use parameters functionally, but preserving them maintains consistency for combinator chains.AggregateFunctionFactory.cpp: Pass the originalparameters(instead ofArray()) when wrapping Nothing functions with combinators, matching the normal code path.Reproducer (crashes on debug builds without fix):
🤖 Generated with Claude Code
Version info
26.4.1.382