Skip to content

Commit

Permalink
opt: fix scalar building error handling
Browse files Browse the repository at this point in the history
We are incorrectly returning `nil` error in an error case. This leads
to an assertion error instead of a "could not decorrelate subquery"
error.

Fixes cockroachdb#40590.

Release note: None
  • Loading branch information
RaduBerinde committed Oct 17, 2019
1 parent 2859f9b commit 58078de
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
33 changes: 33 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/apply_join
Original file line number Diff line number Diff line change
Expand Up @@ -289,3 +289,36 @@ query II
SELECT a, (SELECT a FROM y) FROM x
----
1 1

# Regression test for #40590: non-executable apply join inside apply join.

statement ok
CREATE TABLE IF NOT EXISTS tab_orig AS
SELECT
'2001-01-01'::TIMESTAMP + g * '1 day' AS _timestamp,
g AS _string
FROM
generate_series(NULL, NULL) AS g;

statement error could not decorrelate subquery
SELECT
NULL
FROM
tab_orig AS tab_9962,
tab_orig AS tab_9963
JOIN tab_orig AS tab_9964 ON true
WHERE
NOT
(
tab_9964._timestamp
IN (SELECT tab_9962._timestamp)
OR EXISTS(
WITH
with_2063 AS (SELECT NULL)
SELECT
COALESCE(
tab_9962._string,
tab_9963._string
)
)
)
2 changes: 1 addition & 1 deletion pkg/sql/opt/exec/execbuilder/relational_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ func (b *Builder) buildApplyJoin(join memo.RelExpr) (execPlan, error) {
if len(*filters) != 0 {
onExpr, err = b.buildScalar(&ctx, filters)
if err != nil {
return execPlan{}, nil
return execPlan{}, err
}
}

Expand Down

0 comments on commit 58078de

Please sign in to comment.