cloud-fan commented on a change in pull request #24149: [SPARK-27207][SQL] :
Ensure aggregate buffers are initialized again for So…
URL: https://github.com/apache/spark/pull/24149#discussion_r281725660
##########
File path:
sql/core/src/test/scala/org/apache/spark/sql/TypedImperativeAggregateSuite.scala
##########
@@ -299,5 +313,62 @@ object TypedImperativeAggregateSuite {
}
}
+ /**
+ * SPARK-27207: Dummy UDAF to test whether aggregate buffers are
reinitialized for
+ * SortBasedAggregate in aggregation buffer.
+ */
+ private case class TypedMax2(
+ child: Expression,
+ nullable: Boolean = false,
+ mutableAggBufferOffset: Int = 0,
+ inputAggBufferOffset: Int = 0)
+ extends TypedImperativeAggregate[MaxValue] with ImplicitCastInputTypes {
+
+
+ var initialized = false
+ override def createAggregationBuffer(): MaxValue = {
+ initialized = true
+ null
+ }
+
+ override def update(buffer: MaxValue, input: InternalRow): MaxValue = {
+ // The below if condition will fail if initialize() is not called
+ assert(initialized)
+ null
+ }
+
+ override def merge(bufferMax: MaxValue, inputMax: MaxValue): MaxValue = {
+ // The below if condition will fail if initialize() is not called
+ assert(initialized)
+ null
+ }
+
+ override def eval(bufferMax: MaxValue): Any = {
+ null
+ }
+
+ override lazy val deterministic: Boolean = true
Review comment:
is this needed?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]