{"record":{"id":"1808125b11637993","repo":"hasura/graphql-engine","slug":"the-aggregation-function-aggregation-function-na","errorCode":null,"errorMessage":"the aggregation function '{aggregation_function_name}' is not defined in the aggregate expression '{aggregate_expression}'","messagePattern":"the aggregation function '(.+?)' is not 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":168,"sourceCode":"    },\n\n    #[error(\n        \"the operand type '{operand_type}' does not match the operand type '{aggregate_operand}' from the aggregate expression '{aggregate_expression}'\"\n    )]\n    AggregateOperandTypeMismatch {\n        operand_type: QualifiedTypeName,\n        aggregate_expression: Qualified<AggregateExpressionName>,\n        aggregate_operand: QualifiedTypeName,\n    },\n\n    #[error(\n        \"the aggregate function '{aggregation_function_name}' is defined more than once in the comparable aggregation functions\"\n    )]\n    DuplicateAggregationFunctionFound {\n        aggregation_function_name: AggregationFunctionName,\n    },\n\n    #[error(\n        \"the aggregation function '{aggregation_function_name}' is not defined in the aggregate expression '{aggregate_expression}'\"\n    )]\n    AggregationFunctionNotFound {\n        aggregation_function_name: AggregationFunctionName,\n        aggregate_expression: Qualified<AggregateExpressionName>,\n    },\n\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 {","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/metadata-resolve/src/stages/aggregate_boolean_expressions/types.rs#L150-L186","documentation":"AggregateBooleanExpressionError::AggregationFunctionNotFound: the boolean expression declares an aggregation function (e.g. avg) that is not among the aggregation functions defined by the referenced aggregate expression. Both the function name and the aggregate expression name are reported.","triggerScenarios":"Listing a comparable aggregation function on a boolean expression that the target aggregate expression does not define, e.g. requiring avg when the aggregate expression only defines max/min/count.","commonSituations":"Assuming standard SQL aggregate functions exist on a custom aggregate expression, updating an aggregate expression to drop a function while boolean expressions still reference it, typos in function names.","solutions":["Add the missing aggregation function to the aggregate expression's definition","Or remove/rename the aggregation function reference in the boolean expression","Check for typos (avg vs average) against the aggregate expression's declared function names"],"exampleFix":"# before\naggregate_expression: stats.Scores   # defines max, min\ncomparable:\n  functions: [max, avg]   # avg not defined\n\n# after\ncomparable:\n  functions: [max, min]","handlingStrategy":"validation","validationCode":"fn function_defined(aggregate: &AggregateExpression, f: &str) -> bool {\n    aggregate.functions.iter().any(|d| d.name.as_str() == f)\n}","typeGuard":null,"tryCatchPattern":"if let AggregateBooleanExpressionError::AggregationFunctionNotFound { aggregation_function_name, aggregate_expression } = err {\n    eprintln!(\"'{aggregation_function_name}' is not defined by {aggregate_expression:?}\");\n}","preventionTips":["Only list aggregation functions the aggregate expression actually defines","Update boolean expressions when removing functions from an aggregate expression","Watch for function-name typos (avg vs average)"],"tags":["metadata","aggregate-expression","unresolved-reference","aggregation"],"backgroundTag":"unresolved-metadata-reference","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}