hasura/graphql-engine · error · AggregateBooleanExpressionError

the type of the comparable field '{field_name}' ({field_type

Error message

the type of the comparable field '{field_name}' ({field_type}) is an array type. Nested aggregation over array types is not supported

What it means

Thrown during metadata resolution when a boolean expression type used for aggregation declares a comparable (aggregatable) field whose underlying type is an array. The aggregate_boolean_expressions stage walks each comparable field of a boolean expression type and refuses to build nested aggregation input types (e.g. _avg, _sum) over array-typed fields, since nested aggregation over arrays is unsupported.

Source

Thrown at v3/crates/metadata-resolve/src/stages/aggregate_boolean_expressions/types.rs:252

    DuplicateComparableFieldsFound { field_name: FieldName },

    #[error(
        "the field '{field_name}' used in comparable fields is not an aggregatable field defined in the aggregate expression '{aggregate_expression}'"
    )]
    ComparableFieldNotFound {
        field_name: FieldName,
        aggregate_expression: Qualified<AggregateExpressionName>,
    },

    #[error(
        "the operand object type '{operand_type}' does not contain the field '{field_name}' used in the comparable fields"
    )]
    ComparableFieldNotFoundOnObjectType {
        operand_type: Qualified<CustomTypeName>,
        field_name: FieldName,
    },

    #[error(
        "the type of the comparable field '{field_name}' ({field_type}) is an array type. Nested aggregation over array types is not supported"
    )]
    ComparableFieldNestedArrayTypeNotSupported {
        field_name: FieldName,
        field_type: QualifiedTypeReference,
    },

    #[error(
        "the boolean expression type ({boolean_expression_type}) used in the comparable field '{field_name}' could not be found"
    )]
    ComparableFieldBooleanExpressionNotFound {
        field_name: FieldName,
        boolean_expression_type: Qualified<CustomTypeName>,
    },

    #[error(
        "the boolean expression type ({boolean_expression_type}) used in the comparable field '{field_name}' must have a '{aggregate_operand_type}' operand, to match the field type '{field_type}'"
    )]

View on GitHub (pinned to 724551b9ae)

Solutions

  1. Change the field's type in the metadata so it is not an array (e.g. move the comparable field to a related object type reachable via an object relationship instead of an array relationship)
  2. Remove the field from the comparable/aggregate fields of the boolean expression type
  3. Redesign the aggregation as a top-level nested aggregate on the related model using a proper comparable relationship instead of an array-typed field

Example fix

// before (boolean expression type exposing an array-typed comparable field)
objectType:
  name: article_aggregate_bool_exp
  fields:
    - name: tags
      # tags: [Tag!]! -> array type, triggers error

// after: aggregate through an object relationship's expression type
objectType:
  name: article_aggregate_bool_exp
  fields:
    - name: author
      # author: Author (object relationship), aggregations on Author's fields
Defensive patterns

Strategy: validation

Validate before calling

// before applying metadata, check comparable field types are not arrays
fn comparable_field_is_array(field: &ComparableField, types: &TypeIndex) -> bool {
    types.resolve(&field.field_type).map(|t| t.is_array()).unwrap_or(false)
}
assert!(comparable_fields.iter().all(|f| !comparable_field_is_array(f, &types)));

Prevention

When it happens

Trigger: Defining a boolean expression type with a comparable field (e.g. a nested object type used for aggregation filters) where the field's QualifiedTypeReference resolves to an array type, then running metadata resolve/build on that OpenDD metadata.

Common situations: A model has an array of objects/arrays relationship and the developer expects to aggregate inside it (e.g. where: {items: {count: {}}}) but the boolean expression type for that nested field exposes array-typed comparable fields; also happens after changing a scalar/object field to an array in the metadata without regenerating the corresponding boolean expression types.

Related errors


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