[SPARK-51253][SQL][CONNECT] Mapped KVDS.agg should support sql-expressions #49999
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.
What changes were proposed in this pull request?
In we fixed
KeyValueGroupedDataset.agg(...)
forKeyValueGroupedDatasets
for which the values where mapped. We approached this by transforming the grouping key(s) and the aggregates to use different inputs. Unfortunately we forgot that a user is also allowed to define expressions in sql using theexpr(..)
functionality, this did not work in our approach because the sql expression contains an opaque (from the connect POV) string.We opted to fix this in a way that is not to dissimilar to the classic
KeyValueGroupedDataset
implementation. If the KVDS contains a map values function we execute the function in an intermediate projection, and then we apply the aggregation.Why are the changes needed?
It fixes a bug.
It cleans up a bunch of code in
Does this PR introduce any user-facing change?
No. It fixes a bug.
How was this patch tested?
Existing tests pass. I have modified a test to use expr(...) now.
Was this patch authored or co-authored using generative AI tooling?
No.