-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Subquery Unnesting Agg NULL case workarounds (#257)
- Add an outer join with the deduplicated "left side", and a corresponding projection node, to pass along NULL values as expected. - Add a specific workaround in the projection node to case NULL -> 0 if we have a COUNT(*).
- Loading branch information
Showing
9 changed files
with
492 additions
and
232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
include _basic_tables.slt.part | ||
|
||
# This query has NULL values from the subquery agg. It won't work without the | ||
# outer join fix. | ||
# It also has an out-of-order extern column [#1] | ||
query | ||
select | ||
v1, | ||
v2, | ||
( | ||
select avg(v4) | ||
from t2 | ||
where v4 = v2 | ||
) as avg_v4 | ||
from t1 order by v1; | ||
---- | ||
1 100 NULL | ||
2 200 200.0 | ||
2 250 250.0 | ||
3 300 300.0 | ||
3 300 300.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
include _basic_tables.slt.part | ||
|
||
# This query uses a count(*) agg function, with nulls. Nulls should be | ||
# transformed from NULL to 0 when they come from count(*). | ||
# It won't work without the outer join fix + a special case on count(*). | ||
# It also has an out-of-order extern column [#1] | ||
query | ||
select | ||
v1, | ||
v2, | ||
( | ||
select count(*) | ||
from t2 | ||
where v4 = v2 | ||
) as avg_v4 | ||
from t1 order by v1; | ||
---- | ||
1 100 0 | ||
2 200 1 | ||
2 250 1 | ||
3 300 1 | ||
3 300 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.