bersprockets opened a new pull request #35470:
URL: https://github.com/apache/spark/pull/35470
### What changes were proposed in this pull request?
Change BufferSetterGetterUtils to use `InternalRow.setLong` for
TIMESTAMP_NTZ values rather then `InternalRow.update`.
### Why are the changes needed?
When a query aggregates a TIMESTAMP_NTZ column using a UDAF that extends
`UserDefinedAggregateFunction`, Spark will use `TungstenAggregationIterator`,
which creates an `UnsafeRow` for the low-level aggregation buffer.
However, the wrapper of that buffer (`MutableAggregationBufferImpl`) fails
to properly set up a field setter function for the TIMESTAMP_NTZ column, so it
attempts to call `UnsafeRow.update` on the underlying buffer. The UnsafeRow
instance throws `java.lang.UnsupportedOperationException`:
```
Caused by: java.lang.UnsupportedOperationException
at
org.apache.spark.sql.catalyst.expressions.UnsafeRow.update(UnsafeRow.java:218)
at
org.apache.spark.sql.execution.aggregate.BufferSetterGetterUtils.$anonfun$createSetters$15(udaf.scala:217)
at
org.apache.spark.sql.execution.aggregate.BufferSetterGetterUtils.$anonfun$createSetters$15$adapted(udaf.scala:215)
at
org.apache.spark.sql.execution.aggregate.MutableAggregationBufferImpl.update(udaf.scala:272)
at MyAverage$.initialize(<console>:52)
at
org.apache.spark.sql.execution.aggregate.ScalaUDAF.initialize(udaf.scala:450)
```
See the Jira (SPARK-38146) for a full reproduction example.
Before the fix for SPARK-38133, `UnsafeRow` did not consider TIMESTAMP_NTZ
as mutable or fixed size, so Spark would use `SortBasedAggregationIterator`,
which would created a `GenericInternalRow` for the underlying buffer rather
than an `UnsafeRow` instance. Therefore, before SPARK-38133, a UDAF could
aggegrate a TIMESTAMP_NTZ column.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
Turned back on testing of TIMESTAMP_NTZ in the unit test "udaf with all data
types" in `HashAggregationQuerySuite`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]