{"record":{"id":"039467d66206e705","repo":"vitessio/vitess","slug":"unexpected-table-spec","errorCode":null,"errorMessage":"unexpected table spec","messagePattern":"unexpected table spec","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/schemadiff/errors.go","lineNumber":32,"sourceCode":"limitations under the License.\n*/\n\npackage schemadiff\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\t\"strings\"\n\n\t\"vitess.io/vitess/go/sqlescape\"\n\t\"vitess.io/vitess/go/vt/sqlparser\"\n)\n\nvar (\n\tErrEntityTypeMismatch             = errors.New(\"mismatched entity type\")\n\tErrStrictIndexOrderingUnsupported = errors.New(\"strict index ordering is unsupported\")\n\tErrUnexpectedDiffAction           = errors.New(\"unexpected diff action\")\n\tErrUnexpectedTableSpec            = errors.New(\"unexpected table spec\")\n\tErrExpectedCreateTable            = errors.New(\"expected a CREATE TABLE statement\")\n\tErrExpectedCreateView             = errors.New(\"expected a CREATE VIEW statement\")\n)\n\ntype ImpossibleApplyDiffOrderError struct {\n\tUnorderedDiffs   []EntityDiff\n\tConflictingDiffs []EntityDiff\n}\n\nfunc (e *ImpossibleApplyDiffOrderError) Error() string {\n\tvar b strings.Builder\n\tconflictingStatements := e.ConflictingStatements()\n\tfmt.Fprintf(&b, \"no valid applicable order for diffs. %d diffs found conflicting:\", len(conflictingStatements))\n\tfor _, s := range conflictingStatements {\n\t\tb.WriteString(\"\\n\")\n\t\tb.WriteString(s)\n\t}\n\treturn b.String()","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/schemadiff/errors.go#L14-L50","documentation":"ErrUnexpectedTableSpec indicates schemadiff received a sqlparser.TableSpec it does not expect or cannot handle. Create TABLE entity parsing expects a normal *sqlparser.TableSpec; alternative table constructs produce this sentinel error.","triggerScenarios":"Calling NewCreateTableEntityFromSQL or getCreateTableStatement on a CREATE TABLE whose parsed spec type is not the expected *sqlparser.TableSpec (e.g. CREATE TABLE ... LIKE or other unsupported forms).","commonSituations":"Feeding CREATE TABLE ... AS SELECT or CREATE TABLE ... LIKE statements into schemadiff instead of full column-definition CREATE TABLEs.","solutions":["Use full explicit CREATE TABLE statements (columns and constraints spelled out)","Pre-process the schema to expand CREATE TABLE ... LIKE into concrete definitions","Check the statement parses to a standard TableSpec before passing it to schemadiff"],"exampleFix":"// before\nentity, err := schemadiff.NewCreateTableEntityFromSQL(\"CREATE TABLE t2 LIKE t1\") // unexpected table spec\n// after\nentity, err := schemadiff.NewCreateTableEntityFromSQL(\"CREATE TABLE t2 (id INT PRIMARY KEY)\")","handlingStrategy":"validation","validationCode":"stmt, err := sqlparser.Parse(\"CREATE TABLE t2 LIKE t1\")\nif _, ok := stmt.(*sqlparser.CreateTable); !ok || likeSpeced(stmt) {\n\t// expand into explicit column definitions before schemadiff\n}","typeGuard":null,"tryCatchPattern":"if err != nil {\n\tif errors.Is(err, schemadiff.ErrUnexpectedTableSpec) {\n\t\t// reject or expand the statement\n\t}\n}","preventionTips":["Avoid CREATE TABLE ... LIKE / AS SELECT in managed schemas","Spell out full column definitions","Lint schema DDL before feeding schemadiff"],"tags":["schemadiff","ddl","table-spec"],"backgroundTag":"unsupported-ddl-form","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}