{"record":{"id":"db1a0d2c1047c903","repo":"vitessio/vitess","slug":"cannot-find-column-v-in-table-v","errorCode":null,"errorMessage":"cannot find column %v in table %v","messagePattern":"cannot find column (.+?) in table (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/binlog/keyspace_id_resolver.go","lineNumber":95,"sourceCode":"\t\tcolVindex, err := vindexes.FindVindexForSharding(table.Name.String(), tableSchema.ColumnVindexes)\n\t\tif err != nil {\n\t\t\treturn -1, nil, err\n\t\t}\n\n\t\t// TODO @rafael - when rewriting the mapping function, this will need to change.\n\t\t// for now it's safe to assume the sharding key will be always on index 0.\n\t\tshardingColumnName := colVindex.Columns[0].String()\n\t\tfor i, col := range table.Fields {\n\t\t\tif strings.EqualFold(col.Name, shardingColumnName) {\n\t\t\t\t// We found the column.\n\t\t\t\treturn i, &keyspaceIDResolverFactoryV3{\n\t\t\t\t\t// Only SingleColumn vindexes are returned by FindVindexForSharding.\n\t\t\t\t\tvindex: colVindex.Vindex.(vindexes.SingleColumn),\n\t\t\t\t}, nil\n\t\t\t}\n\t\t}\n\t\t// The column was not found.\n\t\treturn -1, nil, fmt.Errorf(\"cannot find column %v in table %v\", shardingColumnName, table.Name)\n\t}, nil\n}\n\n// keyspaceIDResolverFactoryV3 uses the Vindex to compute the value.\ntype keyspaceIDResolverFactoryV3 struct {\n\tvindex vindexes.SingleColumn\n}\n\nfunc (r *keyspaceIDResolverFactoryV3) keyspaceID(v sqltypes.Value) ([]byte, error) {\n\tdestinations, err := r.vindex.Map(context.TODO(), nil, []sqltypes.Value{v})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif len(destinations) != 1 {\n\t\treturn nil, fmt.Errorf(\"mapping row to keyspace id returned an invalid array of destinations: %v\", key.DestinationsString(destinations))\n\t}\n\tksid, ok := destinations[0].(key.DestinationKeyspaceID)\n\tif !ok || len(ksid) == 0 {","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/binlog/keyspace_id_resolver.go#L77-L113","documentation":"Returned when the column referenced by the vstreamer's keyspace-id mapping (from the vschema) is not present in the table's schema definition as seen in the binlog, so the keyspace id column value cannot be located.","triggerScenarios":"The resolver's returned function is invoked for a table whose declared vindex column (shardingColumnName) does not appear in schema.Table's columns — mismatch between vschema column_vindexes and the actual table schema.","commonSituations":"Renamed/dropped sharding column; vschema lists a column that doesn't exist on the table; case/name mismatch between vschema and MySQL schema.","solutions":["Confirm the column exists: SHOW COLUMNS FROM <table> and compare with the vschema column name.","Update the vschema's column_vindexes to reference the actual column name.","Reload the table schema (restart vttablet or apply schema) so schema.Table matches the vschema."],"exampleFix":"// before\n{\"column_vindexes\":[{\"column\":\"user_id\",\"name\":\"h\"}]}\n// after (column actually named uid)\n{\"column_vindexes\":[{\"column\":\"uid\",\"name\":\"h\"}]}","handlingStrategy":"validation","validationCode":"// verify vschema vindex columns exist in the live table\ncols := getMysqlColumns(t, dbName, tableName)\nfor _, cv := range tableVindexes {\n\tif !contains(cols, cv.Column) {\n\t\treturn fmt.Errorf(\"vindex column %s not in table %s\", cv.Column, tableName)\n\t}\n}","typeGuard":null,"tryCatchPattern":"if err := streamKeyRange(ctx, kr); err != nil {\n\tif strings.Contains(err.Error(), \"cannot find column\") {\n\t\t// fix vschema column name or reload table schema\n\t}\n\treturn err\n}","preventionTips":["After renaming/dropping columns, update column_vindexes in the vschema immediately.","Compare vschema column names against SHOW CREATE TABLE before streaming.","Reload tablet schema (ReloadSchema) after DDL so schema.Table is current."],"tags":["vschema","column","binlog","schema-mismatch"],"backgroundTag":"sharding-column-missing","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}