{"record":{"id":"5687ebcf2296a79f","repo":"hasura/graphql-engine","slug":"the-aggregation-function-field-name-conflicts-wi","errorCode":null,"errorMessage":"the aggregation function {field_name} conflicts with the aggregatable field {field_name} in the aggregate expression {aggregate_expression} is named {field_name}. Either rename the aggregation function or the field","messagePattern":"the aggregation function (.+?) conflicts with the aggregatable field (.+?) in the aggregate expression (.+?) is named (.+?)\\. Either rename the aggregation function or the field","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v3/crates/graphql/schema/src/lib.rs","lineNumber":334,"sourceCode":"    )]\n    InternalCommandArgumentPresetLookupFailure {\n        command_name: Qualified<CommandName>,\n        role: Role,\n    },\n    #[error(\"duplicate field name {field_name} generated while building object type {type_name}\")]\n    DuplicateFieldNameGeneratedInObjectType {\n        field_name: ast::Name,\n        type_name: Qualified<CustomTypeName>,\n    },\n    #[error(\n        \"field name for relationship {relationship_name} of type {type_name} conflicts with the existing field {field_name}\"\n    )]\n    RelationshipFieldNameConflict {\n        relationship_name: RelationshipName,\n        field_name: ast::Name,\n        type_name: Qualified<CustomTypeName>,\n    },\n    #[error(\n        \"the aggregation function {field_name} conflicts with the aggregatable field {field_name} in the aggregate expression {aggregate_expression} is named {field_name}. Either rename the aggregation function or the field\"\n    )]\n    AggregationFunctionFieldNameConflict {\n        aggregate_expression: Qualified<AggregateExpressionName>,\n        field_name: ast::Name,\n    },\n    #[error(\n        \"internal error: duplicate aggregatable field {field_name} in the aggregate expression {aggregate_expression} is named {field_name}\"\n    )]\n    InternalDuplicateAggregatableField {\n        aggregate_expression: Qualified<AggregateExpressionName>,\n        field_name: ast::Name,\n    },\n    #[error(\n        \"internal error: duplicate models with global id implementing the same type {type_name} are found\"\n    )]\n    InternalErrorDuplicateGlobalIdSourceFound { type_name: ast::TypeName },\n    #[error(","sourceCodeStart":316,"sourceCodeEnd":352,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/graphql/schema/src/lib.rs#L316-L352","documentation":"Schema-build error for aggregate expressions: when generating aggregate fields, the aggregation function's field name (e.g. `count`, `sum`) collides with the name of an aggregatable field inside the aggregate expression. The message names the conflicting field and the aggregate expression to fix.","triggerScenarios":"An aggregate expression selects a field whose name equals a generated aggregation function field — e.g. aggregating a column literally named `count` or `avg` so that `count { count }` would be generated.","commonSituations":"Database columns named count/sum/avg/min/max used in aggregations, aggregate expressions built programmatically without checking reserved function names.","solutions":["Rename the aggregatable field (or its GraphQL name mapping) in the aggregate expression","Or rename/override the aggregation function field name if the metadata allows it","Avoid naming columns after aggregation function names when designing the schema"],"exampleFix":"# before: column named \"count\" is aggregated\naggregate { count { count } }\n# after: rename the column's field mapping\naggregate { count { total_count } }","handlingStrategy":"validation","validationCode":"// Guard aggregation field names against function names\nconst FN_NAMES: [&str; 5] = [\"count\", \"sum\", \"avg\", \"min\", \"max\"];\nassert!(!FN_NAMES.contains(&field.graphql_name()), \"field {} collides with aggregation function\", field.graphql_name());","typeGuard":null,"tryCatchPattern":"// Catch Error::AggregationFunctionFieldNameConflict { aggregate_expression, field_name } and rename the aggregatable field","preventionTips":["Avoid naming columns count/sum/avg/min/max","Map DB column names to distinct GraphQL names in metadata"],"tags":["schema-generation","aggregation","name-conflict","hasura"],"backgroundTag":"graphql-schema-field-name-collision","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}