vitessio/vitess · error
cannot find column to use to find keyspace_id for table %v
Error message
cannot find column to use to find keyspace_id for table %v
What it means
The resolverFactory callback for a table map entry must return a column index and resolver used to compute keyspace_id from row data. When it fails (e.g. the table's vindex or PK column cannot be resolved), parseEvents wraps the failure as this error naming the table.
Source
Thrown at go/vt/binlog/binlog_streamer.go:498
tableMaps[tableID] = tce
// Check we're in the right database, and if so, fill
// in more data.
if tm.Database != "" && tm.Database != bls.cp.DBName() {
continue
}
// Find and fill in the table schema.
tce.ti = bls.se.GetTable(sqlparser.NewIdentifierCS(tm.Name))
if tce.ti == nil {
return pos, fmt.Errorf("unknown table %v in schema", tm.Name)
}
// Fill in the resolver if needed.
if bls.resolverFactory != nil {
tce.keyspaceIDIndex, tce.resolver, err = bls.resolverFactory(tce.ti)
if err != nil {
return pos, fmt.Errorf("cannot find column to use to find keyspace_id for table %v", tm.Name)
}
}
// Fill in PK indexes if necessary.
if bls.extractPK {
tce.pkNames = make([]*querypb.Field, len(tce.ti.PKColumns))
tce.pkIndexes = make([]int, len(tce.ti.Fields))
for i := range tce.pkIndexes {
// Put -1 as default in here.
tce.pkIndexes[i] = -1
}
for i, c := range tce.ti.PKColumns {
// Patch in every PK column index.
tce.pkIndexes[c] = i
// Fill in pknames
tce.pkNames[i] = tce.ti.Fields[c]
}
}View on GitHub (pinned to 01a25a7d17)
Solutions
- Ensure the table has a resolvable primary vindex or primary key columns in the vschema
- Fix the resolverFactory configuration (routing rules / vindex mappings) so the table maps to a column
- If the table needs no keyspace resolution (unsharded), configure the streamer so resolverFactory is not invoked for it
- Inspect the underlying err from the factory (it is discarded by this wrap) by testing the factory directly
Defensive patterns
Strategy: validation
Validate before calling
ti := schemaEngine.GetTable(sqlparser.NewIdentifierCS(tableName))
if ti == nil || len(ti.PKColumns) == 0 {
return fmt.Errorf("table %s has no PK/vindex column for keyspace_id", tableName)
} Try / catch
err := streamer.Stream(ctx, signals)
if err != nil && strings.Contains(err.Error(), "cannot find column to use to find keyspace_id") {
// fix vschema vindex config, then restart stream
} Prevention
- Give every streamed sharded table a primary vindex
- Validate vschema before creating workflows
- Keep resolverFactory/routing rules in sync with schema changes
- Avoid PK-less tables in sharded streams
When it happens
Trigger: bls.resolverFactory is set and returns an error for the table in a TABLE_MAP event — typically because no usable column (PK or vindex-mapped column) exists to derive the keyspace_id during row streaming.
Common situations: Table has no primary key and no primary vindex configured; vindex definition missing or wrong in the vschema; legacy sharded keyspaces where the routing rules no longer match the streamed table.
Related errors
- cannot build vschema for keyspace %v: %v
- no vschema definition for table %v
- mapping row to keyspace id returned an invalid array of dest
- could not map %v to a keyspace id, got destination %v
- cannot map vindex to unique keyspace id: %v
AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01).
Data as JSON: /api/errors/e095b5e7d24c1b13.
Report an issue: GitHub.