vitessio/vitess · error

source table %v does not exist

Error message

source table %v does not exist

What it means

During schema copying for a materialize workflow, the materializer looks up the CREATE TABLE DDL for each target table in the source keyspace. This error is thrown when the target table (which must match a source table name) has no corresponding DDL entry fetched from the source database, meaning the table does not exist on the source. It guards against building a copy-schema workflow for a table that cannot be copied.

Source

Thrown at go/vt/vtctl/workflow/materializer.go:369

			}

			createDDL := ts.CreateDdl
			// Make any necessary adjustments to the create DDL.
			if removeAutoInc || createDDL == createDDLAsCopy || createDDL == createDDLAsCopyDropConstraint || createDDL == createDDLAsCopyDropForeignKeys {
				if ts.SourceExpression != "" {
					// Check for table if non-empty SourceExpression.
					sourceTableName, err := mz.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.env.Parser())
					if err != nil {
						return err
					}

					ddl = strippedDDL
				}

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

					ddl = strippedDDL

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Verify the table exists on the source: run SHOW TABLES on the source keyspace and correct the table name in the workflow request
  2. Re-create or restore the missing table on the source before creating the workflow
  3. Use --no-copy-schema (or createDDL mode without copy) if you manage the target schema yourself

Example fix

// before
CreateWorkflow --workflow=sales --target-keyspace=copy --tables=customerss
// after
CreateWorkflow --workflow=sales --target-keyspace=copy --tables=customers
Defensive patterns

Strategy: validation

Validate before calling

tables := []string{"customer", "orders"}
srcTables, _ := vtctlClient.ExecuteCommand(ctx, "SHOW", "TABLES", "FROM", "commerce")
for _, t := range tables {
    if !contains(srcTables, t) {
        return fmt.Errorf("table %s missing on source; fix --tables before CreateWorkflow", t)
    }
}

Try / catch

if err := createWorkflow(ctx, req); err != nil {
    if strings.Contains(err.Error(), "does not exist") {
        // correct table names against SHOW TABLES on source and retry
    }
    return err
}

Prevention

When it happens

Trigger: Running CreateWorkflow/MoveTables or Reshard with CopySchema (default) enabled while one of the requested tables (ts.TargetTable) is missing from the source keyspace's tables, so sourceDDLs lookup fails.

Common situations: Typo in table name in the --tables flag; table exists in target vschema but was dropped on the source; case-sensitivity mismatch between requested name and actual source table; copying schema after source table was renamed during a migration.

Related errors


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