vitessio/vitess · error
target table %v does not exist and there is no create ddl de
Error message
target table %v does not exist and there is no create ddl defined
What it means
During deploySchema, each TableSettings entry must end up with a CREATE statement on the target. If the target table does not exist yet and ts.CreateDdl is empty, the materializer has no way to create it, so it fails with this error.
Source
Thrown at go/vt/wrangler/materializer.go:1186
}
for _, td := range targetSchema.TableDefinitions {
hasTargetTable[td.Name] = true
}
targetTablet, err := mz.wr.ts.GetTablet(ctx, target.PrimaryAlias)
if err != nil {
return err
}
var applyDDLs []string
for _, ts := range mz.ms.TableSettings {
if hasTargetTable[ts.TargetTable] {
// Table already exists.
continue
}
if ts.CreateDdl == "" {
return fmt.Errorf("target table %v does not exist and there is no create ddl defined", ts.TargetTable)
}
var err error
mu.Lock()
if len(sourceDDLs) == 0 {
// only get ddls for tables, once and lazily: if we need to copy the schema from source to target
// we copy schemas from primaries on the source keyspace
// and we have found use cases where user just has a replica (no primary) in the source keyspace
sourceDDLs, err = mz.getSourceTableDDLs(ctx)
}
mu.Unlock()
if err != nil {
log.Error("Error getting DDLs of source tables: " + err.Error())
return err
}
createDDL := ts.CreateDdl
if createDDL == createDDLAsCopy || createDDL == createDDLAsCopyDropConstraint || createDDL == createDDLAsCopyDropForeignKeys {View on GitHub (pinned to 01a25a7d17)
Solutions
- Create the workflow with `--create-ddl=copy` (copies DDL from the source primary), or `--create-ddl=copy-drop-constraints` / `copy-drop-foreign-keys`
- Or specify an explicit CREATE TABLE statement via CreateDdl in the MaterializeSettings / --create-ddl flag
- Or pre-create the target table manually with the correct schema before starting the workflow
Example fix
// before vtctldclient MoveTables --target-keyspace=commerce create --source-keyspace=inventory --tables='customer' // after vtctldclient MoveTables --target-keyspace=commerce create --source-keyspace=inventory --tables='customer' --create-ddl='copy'
Defensive patterns
Strategy: validation
Validate before calling
ts, err := wr.ts.GetTablet(ctx, targetPrimaryAlias) // fetch target schema beforehand
schema, _ := schematools.GetSchema(ctx, wr.ts, wr.tmc, targetPrimaryAlias, &tabletmanagerdatapb.GetSchemaRequest{Tables: []string{"/.*/"}})
for _, tbl := range tables {
if !contains(schema.TableDefinitions, tbl) && createDdl == "" {
return fmt.Errorf("table %s missing on target and no create-ddl given", tbl)
}
} Prevention
- Always pass --create-ddl (e.g. 'copy') when target keyspace may be empty
- Pre-create target tables if you need custom DDL
- Double-check table name spellings in --tables
When it happens
Trigger: MoveTables/Materialize workflow created with a table in --tables/-t (or TableSettings) whose TargetTable does not already exist in the target keyspace, and no CreateDdl (or --create-ddl) was specified.
Common situations: Starting MoveTables into an empty target keyspace without passing --create-ddl=copy; typo in the target table name so it looks nonexistent; target table was dropped between workflow creation and schema deployment.
Related errors
- source shard must have a primary for copying schema: %v
- source and target table names must match for copying schema:
- source table %v does not exist
- source table %v does not exist
- unrecognized statement: %s
AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01).
Data as JSON: /api/errors/d2417d260d7426aa.
Report an issue: GitHub.