`Function::EraseArgument` and deserialization exception
What happens?
Hi DuckDB Team,
I’m encountering an assertion failure when using DuckDB 1.4.0 with the datasketches extension.
Error
Serialization Error: Error during bind of function in deserialization:
Assertion triggered in file "/Users/rusty/Development/all-extensions/extensions/datasketches/duckdb/src/function/function.cpp" on line 176:
arguments.size() == bound_function.arguments.size()Relevant Code
The assertion is in Function::EraseArgument:
void Function::EraseArgument(SimpleFunction &bound_function, vector<unique_ptr<Expression>> &arguments,
idx_t argument_index) {
if (bound_function.original_arguments.empty()) {
bound_function.original_arguments = bound_function.arguments;
}
>>> D_ASSERT(arguments.size() == bound_function.arguments.size());
D_ASSERT(argument_index < arguments.size());
arguments.erase_at(argument_index);
bound_function.arguments.erase_at(argument_index);
}What I’m Doing
In the datasketches extension, I call Function::EraseArgument to strip out constant arguments from aggregate functions. Example:
https://github.com/Query-farm/datasketches/blob/916aaf1a63d56a3384002222d54196360bb0bdb4/src/generated.cpp#L66
- I define the aggregate function with arguments
{LogicalType::INTEGER, LogicalType::INTEGER}. - In the bind function, I check if the first argument is constant. If so, I move it into the bind data and remove the argument via
Function::EraseArgument.
My Question
This seems to imply that I need to provide an additional definition of the function with {LogicalType::INTEGER} (after the constant is removed).
- Is this the correct approach?
- What if no sensible default exists for the “removed” argument—should I still define the alternate signature?
How to Reproduce
You can trigger the exception by:
SELECT datasketch_quantiles(16, 5.0::float);on a debug build of DuckDB with the datasketches extension.
Alternatively, run test_debug in the datasketches repo.
Thanks for clarifying the right way to handle this!
Cheers, Rusty
To Reproduce
See above
OS:
MacOS
DuckDB Version:
1.4.0
DuckDB Client:
CLI
Hardware:
No response
Full Name:
Rusty Conover
Affiliation:
query.farm
What is the latest build you tested with? If possible, we recommend testing with the latest nightly build.
I have tested with a stable release
Did you include all relevant data sets for reproducing the issue?
No - Other reason (please specify in the issue body)
Did you include all code required to reproduce the issue?
- Yes, I have
Did you include all relevant configuration (e.g., CPU architecture, Python version, Linux distribution) to reproduce the issue?
- Yes, I have
Source: duckdb/duckdb