databendlabs/databend · error
not implemented
Error message
not implemented
What it means
`build_aggregator_params` panics with `unimplemented!()` when the aggregate expression uses a UDF whose type is `UDFType::Server(_)`: server-side aggregate UDFs have no supported state-field handling yet. The planner only knows how to build AggregateFunctionParams for builtin/Client aggregate functions.
Solutions
- Reclassify the UDF as UDFType::Client (or implement it as a builtin aggregate function) so the supported branch is taken
- Define the expected state fields for server aggregate UDFs and implement the match arm
- Catch the failure early with a user-facing error (return Err instead of panic) explaining that server aggregate UDFs are unsupported
Example fix
// before
Some((UDFType::Server(_), _state_fields)) => unimplemented!(),
// after
Some((UDFType::Server(name), _)) => Err(ErrorCode::Unimplemented(format!(
"aggregate function '{}' implemented as a server UDF is not supported yet", name))), Defensive patterns
Strategy: validation
Validate before calling
match &agg.func.func_type {
UDFType::Server(_) => return Err(ErrorCode::Unimplemented("server aggregate UDFs are not supported")),
_ => {}
} Prevention
- Only register aggregate UDFs as UDFType::Client
- Test aggregate queries with every registered UDF in CI
- Add an early schema/bind-time check rejecting server aggregate UDFs
When it happens
Trigger: A query registers or invokes an aggregate function resolved as `UDFType::Server(_)` (server aggregate UDF) while building the aggregator parameters for a distributed/cluster plan.
Common situations: Users deploying server-side UDFs and running them as aggregate functions; clusters where a UDF definition classifies the function as Server instead of Client.
Related errors
- internal error: entered unreachable code
- PartitionItem::BucketSpilled(_) => unreachable!()
- AggregateMeta does not support exchanging between multiple…
- _ => unreachable!()
- not implemented: AggregateMeta does not support exchanging…
AI-assisted analysis of databendlabs/databend@288d84d76e (2026-09-11).
Data as JSON: /api/errors/a3b1ee4dbf69e962.
Report an issue: GitHub.
Appendix: source
Thrown at src/query/service/src/pipelines/builders/builder_aggregate.rs:119
code,
agg_func.sig.name.clone(),
agg_func.display.clone(),
state_fields
.iter()
.map(|f| DataField::new(&f.name, f.data_type.clone()))
.collect(),
agg_func
.sig
.args
.iter()
.enumerate()
.map(|(i, data_type)| {
DataField::new(&format!("arg_{}", i), data_type.clone())
})
.collect(),
agg_func.sig.return_type.clone(),
),
Some((UDFType::Server(_), _state_fields)) => unimplemented!(),
}
})
.collect::<Result<_>>()?;
let params = AggregatorParams::try_create(
input_schema,
group_data_types,
&group_by,
&aggs,
&agg_args,
cluster_aggregator,
max_block_rows,
max_block_bytes,
)?;
log::debug!("aggregate states layout: {:?}", params.states_layout);
Ok(params)View on GitHub (pinned to 288d84d76e)