[SPARK-52738][SQL] Support aggregating the TIME type with a UDAF when the underlying buffer is an UnsafeRow
#51430
+12
−8
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?
BufferSetterGetterUtils
to useInternalRow.setLong
for setting TIME values rather thenInternalRow.update
.BufferSetterGetterUtils
to useInternalRow.getLong
for getting TIME values.AggregationQuerySuite
so that it checks aggregation with both an unsafe and safe aggregation buffer. Since SPARK-41359, that test has been testing with only a safe aggregation buffer.Why are the changes needed?
When a query uses a UDAF to aggregate a TIME column , and all other columns are "mutable" (as determined by
UnsafeRow#isMutable
), the aggregator creates anUnsafeRow
for the low-level aggregation buffer.However, the wrapper of that buffer (
MutableAggregationBufferImpl
) fails to properly set up a field setter function for the TIME column, so it attempts to callUnsafeRow.update
on the underlying buffer. TheUnsafeRow
instance throwsorg.apache.spark.SparkUnsupportedOperationException
:See SPARK-52738 for a reproduction example.
Does this PR introduce any user-facing change?
No. The TIME type is not released yet.
How was this patch tested?
Updated a unit test.
Was this patch authored or co-authored using generative AI tooling?
No.