Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions enginetest/query_plans.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,20 @@ var PlanTests = []QueryPlanTest{
" └─ IndexedTableAccess(othertable on [othertable.i2])\n" +
"",
},
{
Query: `SELECT i, i2, s2 FROM mytable INNER JOIN othertable ON i = i2 UNION SELECT i, i2, s2 FROM mytable INNER JOIN othertable ON i = i2`,
ExpectedPlan: "Distinct\n" +
" └─ Union\n" +
" ├─ Project(mytable.i, othertable.i2, othertable.s2)\n" +
" │ └─ IndexedJoin(mytable.i = othertable.i2)\n" +
" │ ├─ Table(mytable)\n" +
" │ └─ IndexedTableAccess(othertable on [othertable.i2])\n" +
" └─ Project(mytable.i, othertable.i2, othertable.s2)\n" +
" └─ IndexedJoin(mytable.i = othertable.i2)\n" +
" ├─ Table(mytable)\n" +
" └─ IndexedTableAccess(othertable on [othertable.i2])\n" +
"",
},
{
Query: `SELECT sub.i, sub.i2, sub.s2, ot.i2, ot.s2 FROM (SELECT i, i2, s2 FROM mytable INNER JOIN othertable ON i = i2) sub INNER JOIN othertable ot ON sub.i = ot.i2`,
ExpectedPlan: "Project(sub.i, sub.i2, sub.s2, ot.i2, ot.s2)\n" +
Expand Down
3 changes: 0 additions & 3 deletions sql/analyzer/resolve_unions.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ func resolveUnions(ctx *sql.Context, a *Analyzer, n sql.Node, scope *Scope) (sql
}

func finalizeUnions(ctx *sql.Context, a *Analyzer, n sql.Node, scope *Scope) (sql.Node, error) {
if n.Resolved() {
return n, nil
}
// Procedures explicitly handle unions
if _, ok := n.(*plan.CreateProcedure); ok {
return n, nil
Expand Down