Skip to content

Disable AGG(IF()) rewrite for some corner cases#16566

Merged
highker merged 2 commits intoprestodb:masterfrom
yuanzhanhku:second
Aug 6, 2021
Merged

Disable AGG(IF()) rewrite for some corner cases#16566
highker merged 2 commits intoprestodb:masterfrom
yuanzhanhku:second

Conversation

@yuanzhanhku
Copy link
Contributor

The rewrite could change the behavior of certain aggregations such as
set_agg(). See the added tests for example. To be safe, we disable it
for all aggregation functions returning arrays.

Test plan
Added query tests in TestFilteredAggregations.java.

== NO RELEASE NOTE ==

@yuanzhanhku yuanzhanhku requested review from highker and kaikalur August 5, 2021 03:56
@yuanzhanhku yuanzhanhku force-pushed the second branch 2 times, most recently from 05985bb to 36c9af2 Compare August 5, 2021 17:33
@yuanzhanhku yuanzhanhku changed the title Disable AGG(IF()) rewrite when returning arrays Disable AGG(IF()) rewrite for some corner cases Aug 5, 2021
@yuanzhanhku yuanzhanhku linked an issue Aug 5, 2021 that may be closed by this pull request
This rewrite will filter out the null values. It could change the
behavior if the aggregation is also applied on NULLs.

Also change SetAggregationFunction::isCalledOnNullInput and
SetUnionFunction::isCalledOnNullInput to return true,
as they are actually applied on NULL inputs.

Add more tests for AGG(IF()) rewrites.
Not sure if non-deterministic functions could cause issues.
But to be safe, disable the rewrite when the IF contains any
non-deterministic functions to avoid some corner cases.
@yuanzhanhku yuanzhanhku requested a review from highker August 6, 2021 16:08
@highker highker merged commit b8e105f into prestodb:master Aug 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a rule to rewrite AGG(IF()) to AGG() WITH FILTER

3 participants