Repository navigation
fix(spark): report aggregate DISTINCT handling - #26753
Draft
Dodothereal wants to merge 1 commit into
Draft
Dodothereal wants to merge 1 commit into
Dodothereal wants to merge 1 commit into
Conversation
The Spark aggregates all used the default Sensitive declaration, although collect_set always deduplicates and the other three accumulators do not read DISTINCT at all. Record what each implementation actually does so the optimizer can remove a redundant modifier from collect_set. The Unsupported declarations document the current gap for collect_list, try_sum, and avg. Nothing rejects those forms yet, so their behavior is 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.
Closes #25375.
The Spark aggregates all reported the default
Sensitivehandling forDISTINCT, even though their accumulators behave differently.collect_setalways deduplicates, whilecollect_list,try_sum, andavgdo not read theDISTINCTflag.This declares
collect_setasInsensitiveand the other three asUnsupported. The optimizer can now remove a redundantDISTINCTfromcollect_set. For the other functions, this records the current gap; it does not make their accumulators supportDISTINCT.Making
Unsupportedexplicit is conservative for join elimination: an aggregate with a filter no longer counts as duplicate-insensitive and therefore keeps an inner join instead of being eliminated as a semijoin.SingleDistinctToGroupBystill deduplicates single-argument forms, so their results stay the same.The tests cover the four declarations and check through
EXPLAINthatcollect_set(DISTINCT a)is planned ascollect_set(a). A result test with duplicates covers the same path.Tests run:
cargo test -p datafusion-spark --lib aggregatecargo test -p datafusion-sqllogictest --test sqllogictests -- spark/aggregate/collect --test-threads 1cargo test -p datafusion-optimizer --libcargo clippy -p datafusion-spark --lib -- -D warningscargo fmt --all -- --check