{"record":{"id":"7ced4d797f306f85","repo":"hasura/graphql-engine","slug":"the-aggregation-function-aggregation-function-na-7ced4d","errorCode":null,"errorMessage":"the aggregation function '{aggregation_function_name}' returns an array type ({aggregation_function_return_type}). Array types are not supported in aggregate comparisons","messagePattern":"the aggregation function '(.+?)' returns an array type \\((.+?)\\)\\. Array types are not supported in aggregate comparisons","errorType":"validation","errorClass":"AggregateBooleanExpressionError","httpStatus":null,"severity":"error","filePath":"v3/crates/metadata-resolve/src/stages/aggregate_boolean_expressions/types.rs","lineNumber":193,"sourceCode":"\n    #[error(\n        \"could not find a scalar-operanded boolean expression type named '{boolean_expression_type}'\"\n    )]\n    ScalarBooleanExpressionTypeNotFound {\n        boolean_expression_type: BooleanExpressionTypeIdentifier,\n    },\n\n    #[error(\n        \"type mismatch between the aggregation function '{aggregation_function_name}' (return type: '{aggregation_function_return_type}') and the specified boolean expression type '{boolean_expression_type}' (operand type: '{boolean_expression_operand_type}')\"\n    )]\n    AggregationFunctionTypeMismatch {\n        aggregation_function_name: AggregationFunctionName,\n        aggregation_function_return_type: QualifiedTypeName,\n        boolean_expression_type: BooleanExpressionTypeIdentifier,\n        boolean_expression_operand_type: QualifiedTypeName,\n    },\n\n    #[error(\n        \"the aggregation function '{aggregation_function_name}' returns an array type ({aggregation_function_return_type}). Array types are not supported in aggregate comparisons\"\n    )]\n    ComparisonAgainstArrayTypesNotSupported {\n        aggregation_function_name: AggregationFunctionName,\n        aggregation_function_return_type: QualifiedTypeReference,\n    },\n\n    #[error(\n        \"the {count_type} aggregation cannot be compared to because it is not enabled on the aggregate expression '{aggregate_expression}'\"\n    )]\n    CountAggregateNotEnabled {\n        count_type: CountAggregateType,\n        aggregate_expression: Qualified<AggregateExpressionName>,\n    },\n\n    #[error(\n        \"type mismatch between the '{count_type}' aggregate (return type: '{count_return_type}') and the specified boolean expression type '{boolean_expression_type}' (operand type: '{boolean_expression_operand_type}')\"\n    )]","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/metadata-resolve/src/stages/aggregate_boolean_expressions/types.rs#L175-L211","documentation":"Aggregate comparisons must compare against scalar values; this error is raised when the selected aggregation function's resolved return type is an array (e.g. array_agg or a connector-defined array-returning function). Comparing an array-typed result with scalar comparison operators is not supported, so resolution aborts.","triggerScenarios":"Using an aggregation function that returns an array type (like array_agg) inside a comparative aggregate / aggregate boolean expression where scalar comparisons (_eq, _gt, etc.) are expected.","commonSituations":"Adding array_agg or custom array-returning aggregate functions to connector capabilities and then attempting to filter on them; changing a custom aggregate function's return type from scalar to array in a new connector version while metadata still uses it in comparisons.","solutions":["Remove the array-returning aggregate from the comparison and use a scalar-returning aggregate instead","If you need to filter on array contents, restructure the query/model to expose a scalar aggregate or filter at the row level","Update connector metadata so the aggregate function returns a scalar type if the array return was unintentional"],"exampleFix":"// before\nfilter: { array_agg_field: { _eq: 1 } }\n\n// after\nfilter: { count_field: { _eq: 1 } } // scalar-returning aggregate","handlingStrategy":"validation","validationCode":"if agg_fn.return_type.is_array() {\n    return Err(\"cannot compare array-returning aggregate; choose a scalar aggregate\".into());\n}","typeGuard":"fn is_scalar_type(r: &QualifiedTypeReference) -> bool {\n    !matches!(r.underlying(), Type::Array(_))\n}","tryCatchPattern":"match resolve(expr) {\n    Err(ResolveError::ComparisonAgainstArrayTypesNotSupported { aggregation_function_name, .. }) => {\n        // fall back to a scalar aggregate or reject the query with a user-facing message\n    }\n    r => r,\n}","preventionTips":["When adding custom aggregates, prefer scalar return types for comparable aggregates","Reject array-returning aggregates in query builders before sending to metadata resolution"],"tags":["rust","aggregate","array-type","type-mismatch","metadata"],"backgroundTag":null,"analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}