forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
opt: prepare to support multi-argument aggregate functions
PR cockroachdb#44628 is attempting to add the corr() aggregate function, which will be the first true multi-argument aggregate in CRDB (besides string_agg, which is special-cased). That PR runs into problems when dealing with aggregate DISTINCT and FILTER clauses. The main issue is that the optimizer currently adds the AggDistinct and AggFilter operators as *inputs* to the aggregate function. This doesn't make sense when there are multiple inputs, since it's now ambiguous which input to use for that purpose. This commit flips the situation by wrapping the aggregate function with AggDistinct and AggFilter rather than having them wrap the input to the aggregate function: (AggFilter (AggDistinct (Sum (Variable 1)))) instead of: (Sum (AggFilter (AggDistinct (Variable 1)))) As part of this change, it was also convenient to refactor the EliminateAggDistinctForKeys rule and also to consolidate the ReplaceScalarMinWithLimit and ReplaceScalarMaxWithLimit rules into one rule. Release note: None
- Loading branch information
1 parent
f6bb936
commit 079bc47
Showing
24 changed files
with
636 additions
and
355 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
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
Oops, something went wrong.