{"record":{"id":"4d99d5c4fa1af00e","repo":"hasura/graphql-engine","slug":"the-field-field-name-used-in-comparable-fields","errorCode":null,"errorMessage":"the field '{field_name}' used in comparable fields is not an aggregatable field defined in the aggregate expression '{aggregate_expression}'","messagePattern":"the field '(.+?)' used in comparable fields is not an aggregatable field defined in the aggregate expression '(.+?)'","errorType":"validation","errorClass":"AggregateBooleanExpressionError","httpStatus":null,"severity":"error","filePath":"v3/crates/metadata-resolve/src/stages/aggregate_boolean_expressions/types.rs","lineNumber":236,"sourceCode":"\n    #[error(\n        \"the operand type '{operand_type}' does not match the operand type of the filter boolean expression type '{boolean_expression_type}': '{boolean_expression_operand_type}'\"\n    )]\n    FilterInputFilterExpressionTypeMismatch {\n        operand_type: QualifiedTypeName,\n        boolean_expression_type: Qualified<CustomTypeName>,\n        boolean_expression_operand_type: QualifiedTypeName,\n    },\n\n    #[error(\"the order by expression '{order_by_expression}' could not be found\")]\n    OrderByExpressionNotFound {\n        order_by_expression: Qualified<OrderByExpressionName>,\n    },\n\n    #[error(\"the field '{field_name}' is defined more than once in the comparable fields\")]\n    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    )]","sourceCodeStart":218,"sourceCodeEnd":254,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/metadata-resolve/src/stages/aggregate_boolean_expressions/types.rs#L218-L254","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Remove or correct the field entry in comparable_fields to reference an aggregatable field defined on the aggregate expression","If the field should be comparable, add it as an aggregatable field on the aggregate expression","Regenerate metadata after connector schema changes"],"exampleFix":"// before\ncomparable_fields: [price, nonexistent_field]\n\n// after\ncomparable_fields: [price] // or add nonexistent_field as aggregatable","handlingStrategy":"validation","validationCode":"let aggregatable: HashSet<_> = agg_expr.aggregatable_fields.iter().collect();\nfor f in &comparable_fields {\n    assert!(aggregatable.contains(f), \"{f} is not an aggregatable field\");\n}","typeGuard":"fn is_aggregatable(agg: &AggregateExpression, f: &FieldName) -> bool {\n    agg.aggregatable_fields.contains(f)\n}","tryCatchPattern":"match resolve(expr) {\n    Err(ResolveError::ComparableFieldNotFound { field_name, aggregate_expression }) => {\n        // drop the field from comparable_fields or add it to the aggregate expression\n    }\n    r => r,\n}","preventionTips":["Derive comparable_fields from the aggregate expression's aggregatable fields","Regenerate metadata after connector schema changes"],"tags":["rust","aggregate","comparable-fields","metadata","not-found"],"backgroundTag":null,"analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}