vitessio/vitess · error
column %s not found in schema %v
Error message
column %s not found in schema %v
What it means
For a sharded target keyspace, Vitess picks a primary vindex type based on the source vindex column's MySQL type and must locate that column in the fetched table schema fields. If the column can't be found among the schema fields, preparation fails. The code marks this unreachable because columns are validated earlier, so it usually signals schema drift between validation and use.
Source
Thrown at go/vt/wrangler/materializer.go:752
if targetVSchema.Sharded {
// Choose a primary vindex type for target table based on source specs
var targetVindexType string
var targetVindex *vschemapb.Vindex
for _, field := range tableSchema.TableDefinitions[0].Fields {
if sourceVindexColumns[0] == field.Name {
targetVindexType, err = vindexes.ChooseVindexForType(field.Type)
if err != nil {
return nil, nil, nil, err
}
targetVindex = &vschemapb.Vindex{
Type: targetVindexType,
}
break
}
}
if targetVindex == nil {
// Unreachable. We validated column names when generating the DDL.
return nil, nil, nil, fmt.Errorf("column %s not found in schema %v", sourceVindexColumns[0], tableSchema.TableDefinitions[0])
}
if existing, ok := targetVSchema.Vindexes[targetVindexType]; ok {
if !proto.Equal(existing, targetVindex) {
return nil, nil, nil, fmt.Errorf("a conflicting vindex named %v already exists in the target vschema", targetVindexType)
}
} else {
targetVSchema.Vindexes[targetVindexType] = targetVindex
}
targetTable = &vschemapb.Table{
ColumnVindexes: []*vschemapb.ColumnVindex{{
Column: vindexFromCols[0],
Name: targetVindexType,
}},
}
} else {
targetTable = &vschemapb.Table{}
}View on GitHub (pinned to 01a25a7d17)
Solutions
- Re-run CreateLookupVindex (transient schema-drift issues usually resolve)
- Ensure the vschema ColumnVindex column name matches the actual MySQL column exactly (case included)
- Reload tablet schema (`vtctldclient ReloadSchema`) if the schema was recently altered
Example fix
null
Defensive patterns
Strategy: validation
Validate before calling
tds, _ := schematools.GetSchema(ctx, ts, tmc, primaryAlias, req)
found := false
for _, f := range tds.TableDefinitions[0].Fields {
if f.Name == sourceVindexColumns[0] { found = true }
}
if !found {
return fmt.Errorf("vindex column %s missing from table schema", sourceVindexColumns[0])
} Type guard
func schemaHasColumn(td *tabletmanagerdatapb.TableDefinition, col string) bool {
for _, f := range td.Fields { if f.Name == col { return true } }
return false
} Try / catch
if err := createLookupVindex(...); err != nil {
if strings.Contains(err.Error(), "not found in schema") {
return retryAfterSchemaReload(err) // transient drift: reload and retry
}
return err
} Prevention
- Avoid concurrent ALTER TABLE on the vindex column while creating lookup vindexes
- Keep vschema column names identical (case included) to MySQL column names
- Reload tablet schema after any DDL before running materialization
When it happens
Trigger: sourceVindexColumns[0] not present in tableSchema.TableDefinitions[0].Fields — e.g. the schema was altered between validation and target-vschema generation, or case-sensitivity mismatch between the vschema column name and the MySQL schema.
Common situations: Concurrent DDL renaming/dropping the column mid-command; vschema column spelled differently from the actual MySQL column; schema cache staleness on the tablet.
Related errors
- cannot compile regexp %v for table: %v
- cannot compile regexp %v for excludeTable: %v
- schemas are different: %s: %v, %s: %v
- schemas are different: %s: %v differs from: %s: %v
- %v has an extra table named %v
AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01).
Data as JSON: /api/errors/50478ac3c31647b5.
Report an issue: GitHub.