{"record":{"id":"f60e84d4cb94d0c3","repo":"hasura/graphql-engine","slug":"the-aggregate-expression-aggregate-expression-f60e84","errorCode":null,"errorMessage":"the aggregate expression '{aggregate_expression}' is used with the model '{model_name}' but the {count_type} aggregate's return type ({count_return_type}) does not match the count aggregate scalar type defined by the data connector '{data_connector_name}': {expected_count_return_type}","messagePattern":"the aggregate expression '(.+?)' is used with the model '(.+?)' but the (.+?) aggregate's return type \\((.+?)\\) does not match the count aggregate scalar type defined by the data connector '(.+?)': (.+?)","errorType":"validation","errorClass":"ModelAggregateExpressionError","httpStatus":null,"severity":"error","filePath":"v3/crates/metadata-resolve/src/stages/models/error.rs","lineNumber":295,"sourceCode":"    )]\n    CountReturnTypeMustBeInt {\n        aggregate_expression: Qualified<AggregateExpressionName>,\n        model_name: Qualified<ModelName>,\n        count_type: aggregates::CountAggregateType,\n        data_connector_name: Qualified<DataConnectorName>,\n    },\n    #[error(\n        \"the aggregate expression '{aggregate_expression}' is used with the model '{model_name}' but the {count_type} aggregate's return type ({count_return_type}) does not have a scalar type representation mapping to the '{data_connector_name}' data connector's count aggregate type '{data_connector_count_return_type}'\"\n    )]\n    CountReturnTypeMappingMissing {\n        model_name: Qualified<ModelName>,\n        aggregate_expression: Qualified<AggregateExpressionName>,\n        count_type: aggregates::CountAggregateType,\n        count_return_type: QualifiedTypeName,\n        data_connector_name: Qualified<DataConnectorName>,\n        data_connector_count_return_type: DataConnectorScalarType,\n    },\n    #[error(\n        \"the aggregate expression '{aggregate_expression}' is used with the model '{model_name}' but the {count_type} aggregate's return type ({count_return_type}) does not match the count aggregate scalar type defined by the data connector '{data_connector_name}': {expected_count_return_type}\"\n    )]\n    CountReturnTypeMappingMismatch {\n        model_name: Qualified<ModelName>,\n        aggregate_expression: Qualified<AggregateExpressionName>,\n        count_type: aggregates::CountAggregateType,\n        count_return_type: QualifiedTypeName,\n        data_connector_name: Qualified<DataConnectorName>,\n        expected_count_return_type: QualifiedTypeName,\n    },\n    #[error(\"{0}\")]\n    AggregateExpressionError(#[from] aggregates::AggregateExpressionError),\n}\n","sourceCodeStart":277,"sourceCodeEnd":309,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/metadata-resolve/src/stages/models/error.rs#L277-L309","documentation":"The return type declared for a count aggregate does not match the scalar type the data connector declares for its count aggregate. The resolver compared the aggregate's QualifiedTypeName against the connector's DataConnectorScalarType and found a mismatch.","triggerScenarios":"Declaring count's output type as e.g. Float while the connector declares its count aggregate type as BigInt; mixing Int/BigInt between metadata and connector capabilities.","commonSituations":"Hand-written metadata where count returns a different numeric type than the connector's; connector version upgrades that changed the count scalar type.","solutions":["Align the aggregate's return type with the connector's declared count type","Update the connector capabilities block to declare the count type you actually use","Re-sync metadata after upgrading the connector"],"exampleFix":"// before\ncount:\n  output_type: scalar: Float\n// after\ncount:\n  output_type: scalar: BigInt  # matches connector's count type\n","handlingStrategy":"validation","validationCode":"// assert the aggregate's declared return type equals the connector's count type\nassert_eq!(model.count_output_type, connector.count_aggregate_type);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pin connector versions and re-validate count types on upgrade","Generate aggregate metadata from connector capabilities rather than by hand"],"tags":["hasura","metadata","aggregates","type-mismatch","count"],"backgroundTag":"metadata-type-mismatch","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}