hasura/graphql-engine · error · AggregateBooleanExpressionError

the field '{field_name}' used in comparable fields is not an

Error message

the field '{field_name}' used in comparable fields is not an aggregatable field defined in the aggregate expression '{aggregate_expression}'

What it means

Every field listed in comparable fields must be an aggregatable field defined on the referenced aggregate expression. This error occurs when a comparable field name does not correspond to any aggregatable field of that aggregate expression, so the comparison cannot be resolved.

Source

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

    #[error(
        "the operand type '{operand_type}' does not match the operand type of the filter boolean expression type '{boolean_expression_type}': '{boolean_expression_operand_type}'"
    )]
    FilterInputFilterExpressionTypeMismatch {
        operand_type: QualifiedTypeName,
        boolean_expression_type: Qualified<CustomTypeName>,
        boolean_expression_operand_type: QualifiedTypeName,
    },

    #[error("the order by expression '{order_by_expression}' could not be found")]
    OrderByExpressionNotFound {
        order_by_expression: Qualified<OrderByExpressionName>,
    },

    #[error("the field '{field_name}' is defined more than once in the comparable fields")]
    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"
    )]

View on GitHub (pinned to 724551b9ae)

Solutions

  1. Remove or correct the field entry in comparable_fields to reference an aggregatable field defined on the aggregate expression
  2. If the field should be comparable, add it as an aggregatable field on the aggregate expression
  3. Regenerate metadata after connector schema changes

Example fix

// before
comparable_fields: [price, nonexistent_field]

// after
comparable_fields: [price] // or add nonexistent_field as aggregatable
Defensive patterns

Strategy: validation

Validate before calling

let aggregatable: HashSet<_> = agg_expr.aggregatable_fields.iter().collect();
for f in &comparable_fields {
    assert!(aggregatable.contains(f), "{f} is not an aggregatable field");
}

Type guard

fn is_aggregatable(agg: &AggregateExpression, f: &FieldName) -> bool {
    agg.aggregatable_fields.contains(f)
}

Try / catch

match resolve(expr) {
    Err(ResolveError::ComparableFieldNotFound { field_name, aggregate_expression }) => {
        // drop the field from comparable_fields or add it to the aggregate expression
    }
    r => r,
}

Prevention

When it happens

Trigger: Listing a field in comparable_fields that is not exposed as an aggregatable field on the aggregate expression (e.g. a non-aggregatable column, a relationship, or a typo).

Common situations: Renaming or removing an aggregatable field from the aggregate expression while comparable_fields still lists the old name; adding relationship or computed fields to comparable_fields by mistake; connector schema changes dropping a column.

Related errors


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