{"record":{"id":"769fb7ab3697eee2","repo":"hasura/graphql-engine","slug":"the-aggregate-expression-aggregate-expression-769fb7","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 have a scalar type representation mapping to the '{data_connector_name}' data connector's count aggregate type '{data_connector_count_return_type}'","messagePattern":"the aggregate expression '(.+?)' is used with the model '(.+?)' but the (.+?) aggregate's return type \\((.+?)\\) does not have a scalar type representation mapping to the '(.+?)' data connector's count aggregate type '(.+?)'","errorType":"validation","errorClass":"ModelAggregateExpressionError","httpStatus":null,"severity":"error","filePath":"v3/crates/metadata-resolve/src/stages/models/error.rs","lineNumber":284,"sourceCode":"    },\n    #[error(\n        \"error in aggregate expression {aggregate_expression} used with the model {model_name}: {object_type_error}\"\n    )]\n    ModelAggregateObjectTypeError {\n        model_name: Qualified<ModelName>,\n        aggregate_expression: Qualified<AggregateExpressionName>,\n        object_type_error: object_types::ObjectTypesError,\n    },\n    #[error(\n        \"the aggregate expression '{aggregate_expression}' used with model '{model_name}' must use the Int type for its {count_type} aggregate as the data connector '{data_connector_name}' does not specify a count type in its schema\"\n    )]\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,","sourceCodeStart":266,"sourceCodeEnd":302,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/metadata-resolve/src/stages/models/error.rs#L266-L302","documentation":"During metadata resolution, an aggregate expression uses the count (or single-row count) aggregate, but the return type of the aggregate cannot be mapped to the data connector's declared count aggregate type. The resolver found no scalar type representation mapping between the model's count return type and the connector's expected count type.","triggerScenarios":"Defining a selectAggregate with count on a model backed by a data connector whose scalar types don't include a representation for the count aggregate's return type (e.g. an exotic scalar type set).","commonSituations":"Custom/third-party data connectors that don't declare a count-compatible scalar type; changing a model's count return type; upgrading the connector SDK where count type mappings changed.","solutions":["Check the connector's scalar_types for a type flagged as the aggregate count type and add a mapping for it","Change the aggregate's return type to one the connector maps (e.g. Int/BigInt)","Regenerate/refresh connector capabilities in metadata after connector upgrades"],"exampleFix":"// before\naggregates:\n  count:\n    output_type: scalar: MyCustomCounter\n// after\naggregates:\n  count:\n    output_type: scalar: Int\n","handlingStrategy":"validation","validationCode":"// before applying metadata, check the connector's scalar types include a representation for the count type\nlet count_type = metadata.model_aggregates.count.output_type;\nassert!(connector.scalar_types.iter().any(|s| s.representations_contain(count_type)), \"count type has no connector representation\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep aggregate return types to standard numerics (Int/BigInt)","Run metadata validation/linting in CI before applying"],"tags":["hasura","metadata","aggregates","data-connector","scalar-type"],"backgroundTag":"metadata-type-mapping-missing","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}