-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
aggregate_statistics should only optimize MIN/MAX when relation is not empty #8914
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3260,3 +3260,37 @@ query I | |
select count(*) from (select count(*) a, count(*) b from (select 1)); | ||
---- | ||
1 | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we also add another test where there is a single row that doesn't actually pass the predicate? Like
So the table is not actually empty but the filter removes it all There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good idea. Added that one. |
||
# rule `aggregate_statistics` should not optimize MIN/MAX to wrong values on empty relation | ||
|
||
statement ok | ||
CREATE TABLE empty(col0 INTEGER); | ||
|
||
query I | ||
SELECT MIN(col0) FROM empty WHERE col0=1; | ||
---- | ||
NULL | ||
|
||
query I | ||
SELECT MAX(col0) FROM empty WHERE col0=1; | ||
---- | ||
NULL | ||
|
||
statement ok | ||
DROP TABLE empty; | ||
|
||
statement ok | ||
CREATE TABLE t(col0 INTEGER) as VALUES(2); | ||
|
||
query I | ||
SELECT MIN(col0) FROM t WHERE col0=1; | ||
---- | ||
NULL | ||
|
||
query I | ||
SELECT MAX(col0) FROM t WHERE col0=1; | ||
---- | ||
NULL | ||
|
||
statement ok | ||
DROP TABLE t; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could optimize MIN/MAX if the relation is empty (i.e., return NULL directly). Since it is not the issue itself, I will leave it as follow up.