{"record":{"id":"849a60b884970a60","repo":"temporalio/temporal","slug":"only-comparison-and-and-expression-is-supported","errorCode":null,"errorMessage":"only comparison and \"and\" expression is supported","messagePattern":"only comparison and \"and\" expression is supported","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/archiver/gcloud/query_parser.go","lineNumber":91,"sourceCode":"\t}\n\n\treturn parsedQuery, nil\n}\n\nfunc (p *queryParser) convertWhereExpr(expr sqlparser.Expr, parsedQuery *parsedQuery) error {\n\tif expr == nil {\n\t\treturn errors.New(\"where expression is nil\")\n\t}\n\n\tswitch expr := expr.(type) {\n\tcase *sqlparser.ComparisonExpr:\n\t\treturn p.convertComparisonExpr(expr, parsedQuery)\n\tcase *sqlparser.AndExpr:\n\t\treturn p.convertAndExpr(expr, parsedQuery)\n\tcase *sqlparser.ParenExpr:\n\t\treturn p.convertParenExpr(expr, parsedQuery)\n\tdefault:\n\t\treturn errors.New(\"only comparison and \\\"and\\\" expression is supported\")\n\t}\n}\n\nfunc (p *queryParser) convertParenExpr(parenExpr *sqlparser.ParenExpr, parsedQuery *parsedQuery) error {\n\treturn p.convertWhereExpr(parenExpr.Expr, parsedQuery)\n}\n\nfunc (p *queryParser) convertAndExpr(andExpr *sqlparser.AndExpr, parsedQuery *parsedQuery) error {\n\tif err := p.convertWhereExpr(andExpr.Left, parsedQuery); err != nil {\n\t\treturn err\n\t}\n\treturn p.convertWhereExpr(andExpr.Right, parsedQuery)\n}\n\nfunc (p *queryParser) convertComparisonExpr(compExpr *sqlparser.ComparisonExpr, parsedQuery *parsedQuery) error {\n\tcolName, ok := compExpr.Left.(*sqlparser.ColName)\n\tif !ok {\n\t\treturn fmt.Errorf(\"invalid filter name: %s\", sqlparser.String(compExpr.Left))","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/temporalio/temporal/blob/bde624efd13fbd3843654058db6d9c716166318b/common/archiver/gcloud/query_parser.go#L73-L109","documentation":"Thrown by gcloud queryParser.convertWhereExpr when the WHERE clause contains an expression type other than ComparisonExpr, AndExpr, or ParenExpr. The GCloud archival visibility parser implements only this limited SQL subset; OR, NOT, arithmetic, and other sqlparser node kinds are unsupported.","triggerScenarios":"Parse(\"WorkflowId = 'x' OR RunId = 'y'\") — OrExpr hits the default branch. Same for NOT expressions, function calls, or nested subqueries in the WHERE clause.","commonSituations":"Users familiar with full SQL or Elasticsearch query syntax write `StartTime > '...' OR CloseTime < '...'` or `NOT WorkflowType = 'x'` against GCloud archival visibility and get this error.","solutions":["Rewrite the query using only `=` comparisons, `AND`, and parentheses; OR must be expanded into separate queries.","Replace NOT conditions with their positive comparison equivalent.","If OR semantics are required, use Elasticsearch or SQL visibility instead of the GCloud archival visibility store.","Note ComparisonExpr covers all comparison operators (=, <, >, <=, >=, !=), so range conditions are fine as long as they are joined with AND."],"exampleFix":"// before\nq := \"WorkflowType = 'pay' OR WorkflowType = 'refund'\"\nparsed, err := parser.Parse(q) // error: only comparison and \"and\" expression is supported\n\n// after\n// run one query per workflow type, or use ES/SQL visibility\nq := \"WorkflowType = 'pay' AND StartTime = '2024-01-01T00:00:00Z' AND SearchPrecision = 'Day'\"\nparsed, err := parser.Parse(q)","handlingStrategy":"validation","validationCode":"if strings.Contains(strings.ToLower(query), \" or \") || strings.Contains(strings.ToLower(query), \"not \") {\n\treturn nil, errors.New(\"gcloud archival visibility supports only comparisons joined by AND\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Restrict query builders to Comparison + AND + parentheses grammar.","Expand OR into separate queries client-side and merge results.","Route complex queries to Elasticsearch/SQL visibility instead of the archival store.","Add a lightweight keyword pre-check for OR/NOT before invoking Parse."],"tags":["archival","gcloud","query-parsing","unsupported-operation"],"backgroundTag":"unsupported-query-expression","analyzedSha":"bde624efd13fbd3843654058db6d9c716166318b","analyzedAt":"2026-09-01T07:18:39.080Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}