databendlabs/databend · error

typed calc_domain must be specified

Error message

typed calc_domain must be specified

What it means

`TypedNullaryFunctionBuilder::vectorized` requires a typed `calc_domain` (the function's nullability/domain calculus) to have been set before building the final `FunctionEval::Scalar`. It is `None` here, so the builder panics. `calc_domain` is mandatory because the constant folder consults it for every scalar function evaluation.

Solutions

  1. Call `.calc_domain(...)` on the builder (typically `CalcDomain::full` for functions whose nullability doesn't depend on inputs) before `vectorized`.
  2. Use the crate's registration macros that supply a default calc_domain for nullary functions.
  3. Review the builder chain so every required setter appears before the terminal build call.

Example fix

// before
let f = TypedNullaryFunctionBuilder::new("pi")
    .return_type(DataType::Number(f64))
    .vectorized(...);
// after
let f = TypedNullaryFunctionBuilder::new("pi")
    .return_type(DataType::Number(f64))
    .calc_domain(CalcDomain::full)
    .vectorized(...);
Defensive patterns

Strategy: validation

Validate before calling

// before vectorized():
assert!(calc_domain_set, "calc_domain must be set before vectorized");

Prevention

When it happens

Trigger: Building a nullary (zero-argument) function via `TypedNullaryFunctionBuilder` and calling `vectorized` without first calling `.calc_domain(...)`, or a code path that conditionally skips the `calc_domain` call.

Common situations: Registering a new zero-argument function (e.g. `now()`, `version()`) and omitting the domain specification; copy-pasting a registration snippet from a non-typed builder; a refactor that renamed the `calc_domain` call site.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of databendlabs/databend@288d84d76e (2026-09-11). Data as JSON: /api/errors/61d79177bd24007b. Report an issue: GitHub.

Appendix: source

Thrown at src/query/expression/src/function/function_builder.rs:387

    pub fn derive_stat(
        mut self,
        func: fn(StatCardinality, ctx: &FunctionContext) -> Result<Option<ReturnStat>, String>,
    ) -> Self {
        self.derive_stat = Some(DeriveStat::Nullary(func));
        self
    }

    pub fn vectorized<F>(self, eval: F) -> B
    where F: VectorizedFn0<O> + 'static {
        let Self {
            builder,
            return_type,
            calc_domain,
            derive_stat,
        } = self;
        let mut builder = builder;
        let calc_domain = calc_domain.expect("typed calc_domain must be specified");

        let signature = FunctionSignature {
            name: builder.name().to_string(),
            args_type: Vec::new(),
            return_type: return_type.clone(),
        };

        let calc_wrapper = TypedNullaryCalcDomain {
            calc_domain,
            return_type: return_type.clone(),
            _marker: PhantomData,
        };
        let eval_wrapper = TypedNullaryFunction {
            func: eval,
            return_type,
            _marker: PhantomData,
        };

View on GitHub (pinned to 288d84d76e)