{"record":{"id":"6624d8ae995b22ff","repo":"SigNoz/signoz","slug":"unsupported-operation-exists-and-not-exists-can-o","errorCode":null,"errorMessage":"unsupported operation, exists and not exists can only be applied on custom attributes or string type columns","messagePattern":"unsupported operation, exists and not exists can only be applied on custom attributes or string type columns","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"pkg/query-service/app/traces/v3/query_builder.go","lineNumber":210,"sourceCode":"\t\t}\n\t}\n\tqueryString := strings.Join(conditions, \" AND \")\n\n\tif len(queryString) > 0 {\n\t\tqueryString = \" AND \" + queryString\n\t}\n\treturn queryString, nil\n}\n\nfunc ExistsSubQueryForFixedColumn(key v3.AttributeKey, op v3.FilterOperator) (string, error) {\n\tif key.DataType == v3.AttributeKeyDataTypeString {\n\t\tif op == v3.FilterOperatorExists {\n\t\t\treturn fmt.Sprintf(\"%s %s ''\", key.Key, tracesOperatorMappingV3[v3.FilterOperatorNotEqual]), nil\n\t\t} else {\n\t\t\treturn fmt.Sprintf(\"%s %s ''\", key.Key, tracesOperatorMappingV3[v3.FilterOperatorEqual]), nil\n\t\t}\n\t} else {\n\t\treturn \"\", fmt.Errorf(\"unsupported operation, exists and not exists can only be applied on custom attributes or string type columns\")\n\t}\n}\n\nfunc handleEmptyValuesInGroupBy(groupBy []v3.AttributeKey) (string, error) {\n\tfilterItems := []v3.FilterItem{}\n\tif len(groupBy) != 0 {\n\t\tfor _, item := range groupBy {\n\t\t\tif !item.IsColumn {\n\t\t\t\tfilterItems = append(filterItems, v3.FilterItem{\n\t\t\t\t\tKey:      item,\n\t\t\t\t\tOperator: v3.FilterOperatorExists,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t}\n\tif len(filterItems) != 0 {\n\t\tfilterSet := v3.FilterSet{\n\t\t\tOperator: \"AND\",","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/query-service/app/traces/v3/query_builder.go#L192-L228","documentation":"ExistsSubQueryForFixedColumn in the v3 traces query builder builds exists/not-exists predicates by comparing the column to ''. This is only valid for custom attributes or string-typed columns; applying exists/nexists to a numeric or other typed fixed column is rejected.","triggerScenarios":"Using the exists or not-exists operator on a fixed traces column (e.g. duration_ns) whose type is not string and is not a custom attribute.","commonSituations":"Users try to filter 'spans that have a duration' via exists; dashboards built generically apply exists to all columns including numeric ones.","solutions":["Remove the exists filter on the non-string fixed column","If you need presence semantics on a numeric column, use a comparison like > 0 instead","Apply exists only to custom attributes or string columns"],"exampleFix":"// before\n{\"key\":\"duration_ns\",\"operator\":\"exists\"}\n\n// after\n{\"key\":\"duration_ns\",\"operator\":\">\",\"value\":0}","handlingStrategy":"type-guard","validationCode":"if isNonStringFixedColumn(item.Key) && (op == v3.FilterOperatorExists || op == v3.FilterOperatorNexists) {\n    return fmt.Errorf(\"exists not allowed on %s\", item.Key.Key)\n}","typeGuard":"func existsAllowed(key v3.AttributeKey) bool {\n    return key.Type == v3.AttributeKeyTypeTag || key.DataType == v3.AttributeKeyDataTypeString\n}","tryCatchPattern":null,"preventionTips":["Hide exists/nexists options for numeric fixed columns in the UI","Prefer > 0 comparisons for numeric presence checks"],"tags":["signoz","traces","exists","query-builder","validation"],"backgroundTag":"unsupported-filter-operator","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}