dgraph-io/dgraph · error

Unhandled aggregator function %q

Error message

Unhandled aggregator function %q

What it means

aggregator.ApplyVal looks up the aggregator's name in the registered function maps (unaryFunctions/binaryFunctions and the aggregation registry). If ag.name does not match any registered aggregator, it returns this error quoting the unknown function name. This means the query requested an aggregation/math function that this Dgraph build does not know.

Source

Thrown at query/aggregator.go:788

	if ag.result.Value == nil {
		ag.result = v
		return nil
	}

	left := ag.result
	if err := ag.matchType(&left, &v); err != nil {
		return err
	}

	if function, ok := binaryFunctions[ag.name]; ok {
		res.Tid = left.Tid
		err := function(&left, &v, &res)
		if err != nil {
			return err
		}
		ag.result = res
	} else {
		return errors.Errorf("Unhandled aggregator function %q", ag.name)
	}

	return nil
}

func (ag *aggregator) Apply(val types.Val) error {
	if ag.result.Value == nil {
		if val.Tid == types.VFloatID {
			// Copy array if it's VFloat, otherwise we overwrite value.
			va := val.Value.([]float32)
			res := make([]float32, len(va))
			copy(res, va)
			ag.result = types.Val{Tid: types.VFloatID, Value: res}
		} else {
			ag.result = val
		}
		ag.count++
		return nil

View on GitHub (pinned to 759e242be6)

Solutions

  1. Check the function name spelling in the query against Dgraph's supported math/aggregation functions
  2. Upgrade the Dgraph server if the function exists only in newer versions
  3. Verify the query variable/alias holding the function name is correct when queries are generated dynamically
  4. Consult the server version's documentation for the available aggregator list

Example fix

// before: unknown function
"math summ(x)"
// after: registered function
"math sum(x)"
Defensive patterns

Strategy: validation

Validate before calling

const SUPPORTED = ['sum','min','max','count','avg','ln','exp','sqrt','floor','ceil','since'];
function validateFn(name) {
  if (!SUPPORTED.includes(name)) throw new Error('Unsupported function: ' + name);
}

Try / catch

try {
  r = await txn.query(q);
} catch (e) {
  if (String(e).includes('Unhandled aggregator function')) {
    console.error('Unknown function:', e.message.match(/"([^"]+)"/)[1]);
  }
  throw e;
}

Prevention

When it happens

Trigger: A query references an aggregator or math function name not present in the registry (typo like 'sums', a function added in a newer Dgraph version, or an unsupported name reaching ApplyVal via processBinary/processUnary or an anonymous caller).

Common situations: Typos in math function names; using a function from a newer Dgraph release on an older server; custom/renamed aggregators; query built programmatically with a wrong function string.

Related errors


AI-assisted analysis of dgraph-io/dgraph@759e242be6 (2026-09-01). Data as JSON: /api/errors/ce7200d236064a67. Report an issue: GitHub.