Skip to content

Commit 0ca241f

Browse files
authored
Merge pull request #3213 from dolthub/angela/fullouterjoin
Copy parent row in fullJoinIter
2 parents c3a64fe + 6164474 commit 0ca241f

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

enginetest/queries/join_queries.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1445,4 +1445,22 @@ LATERAL (
14451445
},
14461446
},
14471447
},
1448+
{
1449+
Name: "full outer join as child of cross join",
1450+
SetUpScript: []string{
1451+
"CREATE TABLE t1(c0 VARCHAR(500) , c1 INT , c2 BOOLEAN);",
1452+
"CREATE TABLE t2(c0 INT , c1 VARCHAR(500) , c2 BOOLEAN);",
1453+
"CREATE TABLE t3(c0 VARCHAR(500) , c1 INT);",
1454+
"INSERT INTO t1 VALUES ('UjhU', 9, TRUE);",
1455+
"INSERT INTO t2 VALUES (5, 'ao', TRUE);",
1456+
"INSERT INTO t3 VALUES ('4GD', 6);",
1457+
},
1458+
Assertions: []ScriptTestAssertion{
1459+
{
1460+
Query: "SELECT t2.c0, t2.c1, t2.c2 FROM t2 FULL OUTER JOIN t3 ON LEFT(t2.c1, 2) = t2.c1 CROSS JOIN (SELECT t1.c0 AS c0 FROM t1) AS vtable0;",
1461+
// TODO: possible type mismatch; 1 should be true
1462+
Expected: []sql.Row{{5, "ao", 1}},
1463+
},
1464+
},
1465+
},
14481466
}

sql/rowexec/join_iters.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,8 +570,9 @@ func (i *fullJoinIter) removeParentRow(r sql.Row) sql.Row {
570570
// buildRow builds the result set row using the rows from the primary and secondary tables
571571
func (i *fullJoinIter) buildRow(primary, secondary sql.Row) sql.Row {
572572
row := make(sql.Row, i.rowSize)
573-
copy(row, primary)
574-
copy(row[len(primary):], secondary)
573+
copy(row, i.parentRow)
574+
copy(row[len(i.parentRow):], primary)
575+
copy(row[len(i.parentRow)+len(primary):], secondary)
575576
return row
576577
}
577578

0 commit comments

Comments
 (0)