{"record":{"id":"97037b578ea6bff8","repo":"vitessio/vitess","slug":"could-not-find-vindex-column-v","errorCode":null,"errorMessage":"could not find vindex column %v","messagePattern":"could not find vindex column (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vtctl/workflow/utils.go","lineNumber":323,"sourceCode":"\t\t\t\tif colExpr, ok := selExpr.Expr.(*sqlparser.ColName); ok {\n\t\t\t\t\tmatch = colExpr.Name\n\t\t\t\t} else {\n\t\t\t\t\t// Cannot match against a complex expression.\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\t\t\tif match.Equal(col) {\n\t\t\t\tcolExpr, ok := selExpr.Expr.(*sqlparser.ColName)\n\t\t\t\tif !ok {\n\t\t\t\t\treturn nil, fmt.Errorf(\"vindex column cannot be a complex expression: %v\", sqlparser.String(selExpr))\n\t\t\t\t}\n\t\t\t\treturn colExpr, nil\n\t\t\t}\n\t\tdefault:\n\t\t\treturn nil, fmt.Errorf(\"unsupported select expression: %v\", sqlparser.String(selExpr))\n\t\t}\n\t}\n\treturn nil, fmt.Errorf(\"could not find vindex column %v\", sqlparser.String(col))\n}\n\nfunc shouldInclude(table string, excludes []string) bool {\n\t// We filter out internal tables elsewhere when processing SchemaDefinition\n\t// structures built from the GetSchema database related API calls. In this\n\t// case, however, the table list comes from the user via the -tables flag\n\t// so we need to filter out internal table names here in case a user has\n\t// explicitly specified some.\n\t// This could happen if there's some automated tooling that creates the list of\n\t// tables to explicitly specify.\n\t// But given that this should never be done in practice, we ignore the request.\n\tif schema.IsInternalOperationTableName(table) {\n\t\treturn false\n\t}\n\treturn !slices.Contains(excludes, table)\n}\n\n// getMigrationID produces a reproducible hash based on the input parameters.","sourceCodeStart":305,"sourceCodeEnd":341,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtctl/workflow/utils.go#L305-L341","documentation":"After scanning every select expression, matchColInSelect did not find the requested vindex column anywhere in the source query's select list, so the rewrite rule cannot be built. The library throws this because a vindex column must be present in the select list for routing/rewriting to work during a workflow.","triggerScenarios":"generateRule asks matchColInSelect for column X (typically a primary-vindex column), but the select list omits it — e.g. `select col1 from t` while the vindex is on `id`; or the column name is misspelled/qualified differently.","commonSituations":"Hand-written filter rules missing the primary vindex column; renamed columns; case-sensitivity or keyspace-qualification mismatches between the rule and the schema.","solutions":["Add the vindex column to the select list of the workflow query/rule (e.g. `select id, col1 from t`).","Verify the column name matches the schema and that it is the correct vindex column (check with `Show` on the table's vindexes).","Regenerate the filter rules instead of hand-writing them, using the MoveTables/Reshard defaults."],"exampleFix":"// before\nrule := \"select col1 from t\" // vindex on id\n// error: could not find vindex column id\n// after\nrule := \"select id, col1 from t\"","handlingStrategy":"validation","validationCode":"// confirm every vindex column appears in the select list\nvindexCols := []string{\"id\"} // from SHOW VINDEXES\nfor _, c := range vindexCols {\n    if !strings.Contains(strings.ToLower(ruleSelectList), strings.ToLower(c)) {\n        return fmt.Errorf(\"vindex column %s missing from select list\", c)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run `SHOW VINDEXES ON <table>` and include all primary-vindex columns in the select list.","Spell-check column names against the live schema before creating workflows.","Use default/generated filter rules; only customize columns you understand."],"tags":["go","vindex","workflow"],"backgroundTag":"vindex-column-not-in-select","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}