hasura/graphql-engine · error · AggregateBooleanExpressionError

the boolean expression type ({boolean_expression_type}) used

Error message

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}'

What it means

The boolean expression type used by a comparable field must expose an operand type that matches the field's own type so aggregation comparisons can be built consistently. This error fires when that boolean expression type does not declare an operand of the required AggregateOperandType (e.g. it only has _comparison for a numeric field, or vice versa).

Source

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

    },

    #[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}'"
    )]
    ComparableFieldBooleanExpressionIncorrectOperandType {
        boolean_expression_type: Qualified<CustomTypeName>,
        aggregate_operand_type: AggregateOperandType,
        field_name: FieldName,
        field_type: QualifiedTypeName,
    },

    #[error(
        "the type of the comparable field '{field_name}' ({field_type}) does not match the operand type of the boolean expression type '{boolean_expression_type}': '{boolean_expression_operand_type}'"
    )]
    ComparableFieldBooleanExpressionTypeMismatch {
        field_name: FieldName,
        field_type: QualifiedTypeName,
        boolean_expression_type: Qualified<CustomTypeName>,
        boolean_expression_operand_type: QualifiedTypeName,
    },

View on GitHub (pinned to 724551b9ae)

Solutions

  1. Point the comparable field at a boolean expression type that declares the required operand type matching the field
  2. Add the missing operand type to the boolean expression type's definition in the metadata
  3. Regenerate/extend the boolean expression type for the field's scalar type using the standard aggregate bool exp pattern

Example fix

// before
// field type is Float but the referenced bool exp type only has a String operand
comparableField:
  fieldName: rating
  booleanExpressionType: string_bool_exp

// after
comparableField:
  fieldName: rating
  booleanExpressionType: float_bool_exp  // declares a matching numeric operand
Defensive patterns

Strategy: validation

Validate before calling

let operands = bool_exp_type.operands();
assert!(operands.contains(&required_operand_for(&field.field_type)),
    "bool exp type lacks operand matching field type");

Prevention

When it happens

Trigger: A comparable field with type T points at a boolean expression type whose operand types (as declared for aggregation, e.g. comparison vs. aggregate operands) do not include the operand type required by T.

Common situations: Reusing an existing boolean expression type (written for equality/comparison filters) as the aggregate bool exp for a numeric/comparable field; mixing up comparison-only expression types with aggregation expression types when wiring comparable fields.

Related errors


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