Repository navigation
feat: native GroupsAccumulator for unordered first_value - #91
Merged
Merged
Conversation
first_value only had a GroupsAccumulator when it had an ORDER BY. Without one, grouped aggregation fell back to GroupsAccumulatorAdapter, which keeps a boxed TrivialFirstValueAccumulator per group. DISTINCT ON without ORDER BY plans as one unordered first_value per selected column, so queries with many distinct keys paid that per-group cost in both time and memory. Add UnorderedFirstValueGroupsAccumulator. It stores values in the existing ValueState implementations plus one is_set bit per group. A group takes the first row that passes the FILTER clause (and, with IGNORE NULLS, is not null) and is never written again, which is the same row TrivialFirstValueAccumulator keeps. The state layout stays [first_value, is_set], so partial and final aggregation are unchanged. Also implements evaluate_preserving and state_preserving. LAST_VALUE and ordered FIRST_VALUE are unchanged.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See apache#27150 for details.
Also implements
evaluate_preserving/state_preserving, which upstream'sfirst_valuedoesn't support yet.