Skip to content

Commit 447dc8f

Browse files
committed
add fix for 9807
1 parent e787e8e commit 447dc8f

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

enginetest/queries/join_queries.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,22 @@ on w = 0;`,
792792
}
793793

794794
var JoinScriptTests = []ScriptTest{
795+
{
796+
// https://github.com/dolthub/dolt/issues/9807
797+
Name: "FULL OUTER JOIN fails with empty subquery",
798+
SetUpScript: []string{
799+
"CREATE TABLE t(c BOOLEAN);",
800+
"INSERT INTO t VALUES (FALSE);",
801+
},
802+
Assertions: []ScriptTestAssertion{
803+
{
804+
Query: "SELECT * FROM ( SELECT c FROM t WHERE c ) sub1 FULL OUTER JOIN ( SELECT 1 AS c ) sub2 ON 1=1;",
805+
Expected: []sql.Row{
806+
{nil, 1},
807+
},
808+
},
809+
},
810+
},
795811
{
796812
Name: "Simple join query",
797813
SetUpScript: []string{},

sql/rowexec/join_iters.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,10 @@ func (i *fullJoinIter) Next(ctx *sql.Context) (sql.Row, error) {
487487
}
488488
i.r = nil
489489
i.leftRow = nil
490+
continue
491+
}
492+
if err != nil {
493+
return nil, err
490494
}
491495

492496
row := i.buildRow(i.leftRow, rightRow)
@@ -512,7 +516,7 @@ func (i *fullJoinIter) Next(ctx *sql.Context) (sql.Row, error) {
512516

513517
for {
514518
if i.r == nil {
515-
iter, err := i.b.Build(ctx, i.rp, i.leftRow)
519+
iter, err := i.b.Build(ctx, i.rp, i.parentRow)
516520
if err != nil {
517521
return nil, err
518522
}

0 commit comments

Comments
 (0)