hasura/graphql-engine · error · ObjectTypesIssue

Multiple {function_name} aggregate functions found for type

Error message

Multiple {function_name} aggregate functions found for type {scalar_type} in data connector {data_connector_name}

What it means

More than one aggregate function with the same function_name is declared for the same scalar type in one data connector. Aggregate function names must be unique per (scalar type, connector) so the resolver can map aggregation fields deterministically.

Source

Thrown at v3/crates/metadata-resolve/src/stages/object_types/types.rs:450

    /// Mapping from an object to their fields, which contain the types of fields.
    Object {
        ndc_object_type_name: DataConnectorObjectType,
        field_mappings: Arc<BTreeMap<FieldName, FieldMapping>>,
    },
}

#[allow(clippy::enum_variant_names)]
#[derive(Debug, thiserror::Error)]
pub enum ObjectTypesIssue {
    #[error(
        "Multiple {operator_name} operators found for type {scalar_type} in data connector {data_connector_name}"
    )]
    DuplicateOperatorsDefined {
        scalar_type: ndc_models::ScalarTypeName,
        operator_name: String,
        data_connector_name: Qualified<DataConnectorName>,
    },
    #[error(
        "Multiple {function_name} aggregate functions found for type {scalar_type} in data connector {data_connector_name}"
    )]
    DuplicateAggregateFunctionsDefined {
        scalar_type: ndc_models::ScalarTypeName,
        function_name: String,
        data_connector_name: Qualified<DataConnectorName>,
    },
    #[error(
        "Multiple {function_name} extraction functions found for type {scalar_type} in data connector {data_connector_name}"
    )]
    DuplicateExtractionFunctionsDefined {
        scalar_type: ndc_models::ScalarTypeName,
        function_name: String,
        data_connector_name: Qualified<DataConnectorName>,
    },
    #[error(
        "the field {field_name:} in {type_name:} should have the type {expected:} for data connector {data_connector:} but the field has type {provided:}"
    )]

View on GitHub (pinned to 724551b9ae)

Solutions

  1. Search the aggregate functions section for the scalar type in that connector and delete the duplicate function_name entry
  2. Rely on the connector's built-in aggregate functions instead of redefining them
  3. Regenerate aggregate function collections with a tool that de-duplicates
Defensive patterns

Strategy: validation

Validate before calling

const seen = new Set();
for (const fn of aggregateFunctions) {
  const key = `${fn.scalar_type}/${fn.function_name}`;
  if (seen.has(key)) throw new Error(`Duplicate aggregate function ${key}`);
  seen.add(key);
}

Prevention

When it happens

Trigger: Metadata or connector schema contains two aggregate function entries with identical names for a scalar type — e.g. adding a custom 'avg' aggregate when the connector already provides one.

Common situations: Hand-added aggregate functions colliding with connector-provided defaults; copy-paste errors in metadata; duplicated entries after metadata merges.

Related errors


AI-assisted analysis of hasura/graphql-engine@724551b9ae (2026-08-28). Data as JSON: /api/errors/022ef39d973589d8. Report an issue: GitHub.