{"record":{"id":"44e81a836cd5fa07","repo":"hasura/graphql-engine","slug":"the-type-of-the-comparable-field-field-name","errorCode":null,"errorMessage":"the type of the comparable field '{field_name}' ({field_type}) is an array type. Nested aggregation over array types is not supported","messagePattern":"the type of the comparable field '(.+?)' \\((.+?)\\) is an array type\\. Nested aggregation over array types is not supported","errorType":"validation","errorClass":"AggregateBooleanExpressionError","httpStatus":null,"severity":"error","filePath":"v3/crates/metadata-resolve/src/stages/aggregate_boolean_expressions/types.rs","lineNumber":252,"sourceCode":"    DuplicateComparableFieldsFound { field_name: FieldName },\n\n    #[error(\n        \"the field '{field_name}' used in comparable fields is not an aggregatable field defined in the aggregate expression '{aggregate_expression}'\"\n    )]\n    ComparableFieldNotFound {\n        field_name: FieldName,\n        aggregate_expression: Qualified<AggregateExpressionName>,\n    },\n\n    #[error(\n        \"the operand object type '{operand_type}' does not contain the field '{field_name}' used in the comparable fields\"\n    )]\n    ComparableFieldNotFoundOnObjectType {\n        operand_type: Qualified<CustomTypeName>,\n        field_name: FieldName,\n    },\n\n    #[error(\n        \"the type of the comparable field '{field_name}' ({field_type}) is an array type. Nested aggregation over array types is not supported\"\n    )]\n    ComparableFieldNestedArrayTypeNotSupported {\n        field_name: FieldName,\n        field_type: QualifiedTypeReference,\n    },\n\n    #[error(\n        \"the boolean expression type ({boolean_expression_type}) used in the comparable field '{field_name}' could not be found\"\n    )]\n    ComparableFieldBooleanExpressionNotFound {\n        field_name: FieldName,\n        boolean_expression_type: Qualified<CustomTypeName>,\n    },\n\n    #[error(\n        \"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}'\"\n    )]","sourceCodeStart":234,"sourceCodeEnd":270,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/metadata-resolve/src/stages/aggregate_boolean_expressions/types.rs#L234-L270","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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)","Remove the field from the comparable/aggregate fields of the boolean expression type","Redesign the aggregation as a top-level nested aggregate on the related model using a proper comparable relationship instead of an array-typed field"],"exampleFix":"// before (boolean expression type exposing an array-typed comparable field)\nobjectType:\n  name: article_aggregate_bool_exp\n  fields:\n    - name: tags\n      # tags: [Tag!]! -> array type, triggers error\n\n// after: aggregate through an object relationship's expression type\nobjectType:\n  name: article_aggregate_bool_exp\n  fields:\n    - name: author\n      # author: Author (object relationship), aggregations on Author's fields","handlingStrategy":"validation","validationCode":"// before applying metadata, check comparable field types are not arrays\nfn comparable_field_is_array(field: &ComparableField, types: &TypeIndex) -> bool {\n    types.resolve(&field.field_type).map(|t| t.is_array()).unwrap_or(false)\n}\nassert!(comparable_fields.iter().all(|f| !comparable_field_is_array(f, &types)));","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Lint metadata to reject array-typed comparable fields before submission","Keep comparable fields on scalar or object-relationship-backed fields only"],"tags":["rust","hasura","metadata","aggregation","boolean-expression","array-type"],"backgroundTag":"metadata-schema-validation-failed","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}