{"record":{"id":"7c915ab60b7445ec","repo":"SigNoz/signoz","slug":"unsupported-reduce-operator-7c915a","errorCode":null,"errorMessage":"unsupported reduce operator","messagePattern":"unsupported reduce operator","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"pkg/query-service/app/traces/v3/query_builder.go","lineNumber":340,"sourceCode":"\treturn strings.Join(having, \" AND \")\n}\n\nfunc ReduceToQuery(query string, reduceTo v3.ReduceToOperator, _ v3.AggregateOperator) (string, error) {\n\n\tvar groupBy string\n\tswitch reduceTo {\n\tcase v3.ReduceToOperatorLast:\n\t\tquery = fmt.Sprintf(\"SELECT anyLast(value) as value, now() as ts FROM (%s) %s\", query, groupBy)\n\tcase v3.ReduceToOperatorSum:\n\t\tquery = fmt.Sprintf(\"SELECT sum(value) as value, now() as ts FROM (%s) %s\", query, groupBy)\n\tcase v3.ReduceToOperatorAvg:\n\t\tquery = fmt.Sprintf(\"SELECT avg(value) as value, now() as ts FROM (%s) %s\", query, groupBy)\n\tcase v3.ReduceToOperatorMax:\n\t\tquery = fmt.Sprintf(\"SELECT max(value) as value, now() as ts FROM (%s) %s\", query, groupBy)\n\tcase v3.ReduceToOperatorMin:\n\t\tquery = fmt.Sprintf(\"SELECT min(value) as value, now() as ts FROM (%s) %s\", query, groupBy)\n\tdefault:\n\t\treturn \"\", fmt.Errorf(\"unsupported reduce operator\")\n\t}\n\treturn query, nil\n}\n\nfunc AddLimitToQuery(query string, limit uint64) string {\n\tif limit == 0 {\n\t\tlimit = 100\n\t}\n\treturn fmt.Sprintf(\"%s LIMIT %d\", query, limit)\n}\n\nfunc AddOffsetToQuery(query string, offset uint64) string {\n\treturn fmt.Sprintf(\"%s OFFSET %d\", query, offset)\n}\n\n// PrepareTracesQuery returns the query string for traces\n// start and end are in epoch millisecond\n// step is in seconds","sourceCodeStart":322,"sourceCodeEnd":358,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/query-service/app/traces/v3/query_builder.go#L322-L358","documentation":"ReduceToQuery in the v3 traces builder maps the requested reduce operator to a ClickHouse aggregate (avg/max/min/sum/rate etc.). Any reduce operator outside the switch's known cases returns this error, meaning the frontend requested a reduction the traces builder cannot express.","triggerScenarios":"Setting BuilderQuery.ReduceTo to a value like p90, count, or an empty string in a traces query that goes through PrepareTracesQuery.","commonSituations":"Custom panels or API calls copying metric query configurations (which support more reduce functions like quantiles) onto trace data sources; version skew where newer reduce operators are sent to an older query-service.","solutions":["Use one of the supported reduce operators (avg, max, min, sum, rate, sum_rate, avg_rate, rate_sum, rate_avg, count, count_rate (check switch cases))","If a quantile is needed, compute it via a custom ClickHouse query","Align query-service and frontend versions so unsupported reduce operators are not offered"],"exampleFix":"// before\nmq.ReduceTo = v3.ReduceToOperatorP90\n\n// after\nmq.ReduceTo = v3.ReduceToOperatorAvg","handlingStrategy":"validation","validationCode":"var supportedReduces = map[v3.ReduceToOperator]bool{v3.ReduceToOperatorAvg:true, v3.ReduceToOperatorMax:true, v3.ReduceToOperatorMin:true}\nif !supportedReduces[mq.ReduceTo] {\n    return fmt.Errorf(\"unsupported reduce operator %s\", mq.ReduceTo)\n}","typeGuard":"func isSupportedReduce(op v3.ReduceToOperator) bool {\n    switch op {\n    case v3.ReduceToOperatorAvg, v3.ReduceToOperatorMax, v3.ReduceToOperatorMin:\n        return true\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Limit the reduce dropdown for traces to implemented operators","Test custom panels against the query-service version in use"],"tags":["signoz","traces","reduce","aggregation","validation"],"backgroundTag":"unsupported-aggregation-operator","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}