vitessio/vitess · error

source table %v does not exist

Error message

source table %v does not exist

What it means

With CreateDdl set to a 'copy' mode, the materializer looks up the source table's CREATE DDL fetched from the source primary (sourceDDLs map keyed by table name). If the TargetTable has no matching table on the source keyspace, it fails because there is no schema to copy.

Source

Thrown at go/vt/wrangler/materializer.go:1218

				return err
			}

			createDDL := ts.CreateDdl
			if createDDL == createDDLAsCopy || createDDL == createDDLAsCopyDropConstraint || createDDL == createDDLAsCopyDropForeignKeys {
				if ts.SourceExpression != "" {
					// Check for table if non-empty SourceExpression.
					sourceTableName, err := mz.wr.env.Parser().TableFromStatement(ts.SourceExpression)
					if err != nil {
						return err
					}
					if sourceTableName.Name.String() != ts.TargetTable {
						return fmt.Errorf("source and target table names must match for copying schema: %v vs %v", sqlparser.String(sourceTableName), ts.TargetTable)
					}
				}

				ddl, ok := sourceDDLs[ts.TargetTable]
				if !ok {
					return fmt.Errorf("source table %v does not exist", ts.TargetTable)
				}

				if createDDL == createDDLAsCopyDropConstraint {
					strippedDDL, err := stripTableConstraints(ddl, mz.wr.env.Parser())
					if err != nil {
						return err
					}

					ddl = strippedDDL
				}

				if createDDL == createDDLAsCopyDropForeignKeys {
					strippedDDL, err := stripTableForeignKeys(ddl, mz.wr.env.Parser())
					if err != nil {
						return err
					}

					ddl = strippedDDL

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Verify the table exists on the source: `vtctldclient GetSchema --table-names=<table> <source-keyspace>`
  2. Fix the table name typo in the workflow configuration
  3. Create the table on the source before re-running, or supply an explicit CreateDdl instead of 'copy'

Example fix

// before
vtctldclient MoveTables --target-keyspace=commerce create --source-keyspace=inventory --tables='custmer' --create-ddl='copy'
// after (correct name or explicit DDL)
vtctldclient MoveTables --target-keyspace=commerce create --source-keyspace=inventory --tables='customer' --create-ddl='copy'
Defensive patterns

Strategy: validation

Validate before calling

present, err := sourceTableExists(ctx, sourceKeyspace, targetTable)
if err != nil { return err }
if !present {
    return fmt.Errorf("table %s does not exist on source keyspace %s", targetTable, sourceKeyspace)
}

Prevention

When it happens

Trigger: MoveTables/Materialize with --create-ddl=copy for a table that does not exist on the source keyspace; typo in table name; table exists on target but was dropped on source; source schema fetched via regex /.*/ didn't include the table (e.g. it's a view excluded from GetSchema).

Common situations: Copying schema for a table renamed on the source; running workflow against a source keyspace that never had the table; stale workflow config after source schema changes.

Related errors


AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01). Data as JSON: /api/errors/16c78e64d39e9f03. Report an issue: GitHub.