{"record":{"id":"72716e0f00b3c6a3","repo":"vitessio/vitess","slug":"unsupported-multiple-keyspace-id-expressions-v","errorCode":null,"errorMessage":"unsupported multiple keyspace_id expressions: %v","messagePattern":"unsupported multiple keyspace_id expressions: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vttablet/tabletmanager/vreplication/table_plan_builder.go","lineNumber":481,"sourceCode":"\t\t}, aliased.Expr)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to find column name for convert using expression: %v, %v\", sqlparser.String(aliased.Expr), err)\n\t\t}\n\t\tselExpr := &sqlparser.ConvertUsingExpr{\n\t\t\tType: \"utf8mb4\",\n\t\t\tExpr: &sqlparser.ColName{Name: colName},\n\t\t}\n\t\tcexpr.expr = expr\n\t\tcexpr.operation = opExpr\n\t\ttpb.sendSelect.AddSelectExpr(&sqlparser.AliasedExpr{Expr: selExpr, As: as})\n\t\tcexpr.references[as.String()] = true\n\t\treturn cexpr, nil\n\t}\n\tif expr, ok := aliased.Expr.(*sqlparser.FuncExpr); ok {\n\t\tswitch fname := expr.Name.Lowered(); fname {\n\t\tcase \"keyspace_id\":\n\t\t\tif len(expr.Exprs) != 0 {\n\t\t\t\treturn nil, fmt.Errorf(\"unsupported multiple keyspace_id expressions: %v\", sqlparser.String(expr))\n\t\t\t}\n\n\t\t\ttpb.sendSelect.AddSelectExpr(&sqlparser.AliasedExpr{Expr: aliased.Expr})\n\t\t\t// The vstreamer responds with \"keyspace_id\" as the field name for this request.\n\t\t\tcexpr.expr = &sqlparser.ColName{Name: sqlparser.NewIdentifierCI(\"keyspace_id\")}\n\t\t\treturn cexpr, nil\n\t\t}\n\t}\n\tif expr, ok := aliased.Expr.(sqlparser.AggrFunc); ok {\n\t\tif sqlparser.IsDistinct(expr) {\n\t\t\treturn nil, fmt.Errorf(\"unsupported distinct expression usage: %v\", sqlparser.String(expr))\n\t\t}\n\t\tswitch fname := expr.AggrName(); fname {\n\t\tcase \"count\":\n\t\t\tif _, ok := expr.(*sqlparser.CountStar); !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"only count(*) is supported: %v\", sqlparser.String(expr))\n\t\t\t}\n\t\t\tcexpr.operation = opCount","sourceCodeStart":463,"sourceCodeEnd":499,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vttablet/tabletmanager/vreplication/table_plan_builder.go#L463-L499","documentation":"The special keyspace_id() function in a filter select list must be called with zero arguments — the vstreamer itself supplies the row's keyspace id. Any argument count other than 0 (typically 1) is rejected with this error.","triggerScenarios":"A filter rule contains `keyspace_id(some_col)` or `keyspace_id(1)` instead of the bare `keyspace_id()`.","commonSituations":"Users assuming keyspace_id() takes a column argument; generators emitting vindex-style calls; confusion with similar functions in other systems.","solutions":["Change the call to bare `keyspace_id()` with no arguments","If you need the value of a vindex column, select the column itself instead","Re-run the workflow after fixing the select expression"],"exampleFix":"// before\nSELECT keyspace_id(user_id) AS keyspace_id FROM t\n// after\nSELECT keyspace_id() AS keyspace_id FROM t","handlingStrategy":"validation","validationCode":"for _, e := range sel.SelectExprs {\n    fe, ok := e.(*sqlparser.FuncExpr)\n    if !ok || fe.Name.Lowered() != \"keyspace_id\" { continue }\n    if len(fe.Exprs) != 0 {\n        return errors.New(\"keyspace_id() takes no arguments\")\n    }\n}","typeGuard":"func isBareKeyspaceID(e sqlparser.SelectExpr) bool {\n    ae, ok := e.(*sqlparser.AliasedExpr)\n    if !ok { return false }\n    fe, ok := ae.Expr.(*sqlparser.FuncExpr)\n    return ok && fe.Name.Lowered() == \"keyspace_id\" && len(fe.Exprs) == 0\n}","tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"keyspace_id\") {\n    return fmt.Errorf(\"use keyspace_id() with no arguments: %w\", err)\n}","preventionTips":["Always call keyspace_id() with zero arguments","Remember vstreamer supplies the keyspace id; never pass a column","Add a lint rule for filter SQL function arity"],"tags":["vreplication","keyspace-id","function-arity","filter-rules"],"backgroundTag":"invalid-function-arguments","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}