The two traversal engines each encode every node's children by hand, and
the existing drift test only asserts that both engines know the same
node TYPES - it cannot see a child FIELD one engine traverses and the
other forgot. A new static test compares, per node type, the fields
referenced by Accept against the fields referenced by Walk's case, and
it immediately found ten drifted fields:
Accept was missing (Walk visited them):
- AlterTableDropPartition.Settings
- CreateDatabase.Name, CreateDatabase.Comment
- CreateTable.Comment
- IntervalFrom.Interval
- ProjectionOrderByClause.Columns
- SelectQuery.DistinctOn
- UUID.Value
Walk was missing (Accept visited them):
- InsertStmt.Values (INSERT ... VALUES rows were never walked)
- SelectQuery.Except
- WhenClause.Else
Also:
- InsertStmt.End() panicked on `INSERT INTO t FORMAT CSV`: with the
data arriving out of band there are no Values and no SelectExpr, and
the method indexed Values[len-1] unguarded. It now falls back to
Format, ColumnNames, then Table.
- InsertStmt.Accept visited Format before Table, violating source
order; it now matches Walk (Table, ColumnNames, Format, Values,
SelectExpr).
- DestinationClause.Accept did not visit its own TableSchema;
CreateMaterializedView.Accept compensated by reaching into its child,
so any other DestinationClause holder silently skipped the schema and
the visit happened outside the destination's Enter/Leave bracket.
The clause now owns its child, and its End() includes the schema.
No golden fixture changed.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Summary
The two traversal engines (Accept/ASTVisitor and Walk) each encode every node's children by hand. The existing drift test (#276) asserts both engines know the same node types — it cannot see a child field that one engine traverses and the other forgot.
This PR adds a static field-level drift test (TestTraversalEnginesVisitSameFields) that compares, per node type, the fields referenced by Accept against the fields referenced by Walk's case arm. It immediately found ten drifted fields:
Accept was missing (Walk visited them):
AlterTableDropPartition.Settings, CreateDatabase.Name, CreateDatabase.Comment, CreateTable.Comment, IntervalFrom.Interval, ProjectionOrderByClause.Columns, SelectQuery.DistinctOn, UUID.Value
Walk was missing (Accept visited them):
InsertStmt.Values (INSERT ... VALUES rows were never walked!), SelectQuery.Except, WhenClause.Else
Also fixed
Tests
No golden fixture changed.
Note: the SelectQuery.Except walk fix overlaps with #279 (which adds Except+Intersect there for the INTERSECT feature) — whichever merges second has a one-line trivial conflict in walk.go.
🤖 Generated with Claude Code