{"record":{"id":"4c629b37278d9bee","repo":"SigNoz/signoz","slug":"unsupported-aggregate-operator-s","errorCode":null,"errorMessage":"unsupported aggregate operator %s","messagePattern":"unsupported aggregate operator (.+?)","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"pkg/query-service/app/traces/v4/query_builder.go","lineNumber":457,"sourceCode":"\t\t\t\tsubQuery, err := existsSubQueryForFixedColumn(mq.AggregateAttribute, v3.FilterOperatorExists)\n\t\t\t\tif err == nil {\n\t\t\t\t\tfilterSubQuery = fmt.Sprintf(\"%s AND %s\", filterSubQuery, subQuery)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tcType := getClickHouseTracesColumnType(mq.AggregateAttribute.Type)\n\t\t\t\tcDataType := getClickHouseTracesColumnDataType(mq.AggregateAttribute.DataType)\n\t\t\t\tfilterSubQuery = fmt.Sprintf(\"%s AND mapContains(%s_%s, '%s')\", filterSubQuery, cType, cDataType, mq.AggregateAttribute.Key)\n\t\t\t}\n\t\t}\n\t\top := \"toFloat64(count())\"\n\t\tquery := fmt.Sprintf(queryTmpl, op, filterSubQuery, groupBy, having, orderBy)\n\t\treturn query, nil\n\tcase v3.AggregateOperatorCountDistinct:\n\t\top := fmt.Sprintf(\"toFloat64(count(distinct(%s)))\", aggregationKey)\n\t\tquery := fmt.Sprintf(queryTmpl, op, filterSubQuery, groupBy, having, orderBy)\n\t\treturn query, nil\n\tdefault:\n\t\treturn \"\", fmt.Errorf(\"unsupported aggregate operator %s\", mq.AggregateOperator)\n\t}\n}\n\n// PrepareTracesQuery returns the query string for traces\n// start and end are in epoch millisecond\n// step is in seconds\nfunc PrepareTracesQuery(start, end int64, panelType v3.PanelType, mq *v3.BuilderQuery, options v3.QBOptions) (string, error) {\n\t// adjust the start and end time to the step interval\n\tif panelType == v3.PanelTypeGraph {\n\t\t// adjust the start and end time to the step interval for graph panel types\n\t\tstart = start - (start % (mq.StepInterval * 1000))\n\t\tend = end - (end % (mq.StepInterval * 1000))\n\t}\n\tif options.GraphLimitQtype == constants.FirstQueryGraphLimit {\n\t\t// give me just the group by names\n\t\tquery, err := buildTracesQuery(start, end, mq.StepInterval, mq, panelType, options)\n\t\tif err != nil {\n\t\t\treturn \"\", err","sourceCodeStart":439,"sourceCodeEnd":475,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/query-service/app/traces/v4/query_builder.go#L439-L475","documentation":"The aggregation switch in buildTracesQuery (v4) handles a fixed set of aggregate operators (count, count_distinct, rate/sum/avg variants, etc.); anything else falls to default and is rejected. This is the last-resort guard for aggregate operators that passed earlier panel-type checks.","triggerScenarios":"Setting mq.AggregateOperator to an operator not implemented in the v4 traces aggregation switch (e.g. quantiles like p95, or an empty string) on a non-no-op traces query.","commonSituations":"Frontends exposing the full metrics operator set (including quantiles) for traces; custom clients sending arbitrary operator strings; version mismatch where newer operators aren't implemented server-side.","solutions":["Use a supported traces aggregate operator (count, count_distinct, sum, avg, min, max, rate variants, etc.)","Compute quantiles via a ClickHouse query builder expression instead","Align frontend and query-service versions"],"exampleFix":"// before\nmq.AggregateOperator = \"p95\"\n\n// after\nmq.AggregateOperator = v3.AggregateOperatorAvg","handlingStrategy":"validation","validationCode":"var supportedAggs = map[v3.AggregateOperator]bool{v3.AggregateOperatorCount: true, v3.AggregateOperatorCountDistinct: true /* etc. */}\nif !supportedAggs[mq.AggregateOperator] {\n    return fmt.Errorf(\"aggregate %s unsupported for traces\", mq.AggregateOperator)\n}","typeGuard":"func isTraceAggregate(op v3.AggregateOperator) bool {\n    switch op {\n    case v3.AggregateOperatorCount, v3.AggregateOperatorCountDistinct:\n        return true\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Restrict traces UI to implemented aggregate operators","Smoke-test custom dashboards against the deployed query-service version"],"tags":["signoz","traces","v4","aggregate","operator"],"backgroundTag":"unsupported-aggregation-operator","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}