Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15703#discussion_r86487495
  
    --- Diff: sql/hive/src/main/scala/org/apache/spark/sql/hive/hiveUDFs.scala 
---
    @@ -365,4 +382,66 @@ private[hive] case class HiveUDAFFunction(
         val distinct = if (isDistinct) "DISTINCT " else " "
         s"$name($distinct${children.map(_.sql).mkString(", ")})"
       }
    +
    +  override def createAggregationBuffer(): AggregationBuffer =
    +    partial1ModeEvaluator.getNewAggregationBuffer
    +
    +  @transient
    +  private lazy val inputProjection = new InterpretedProjection(children)
    +
    +  override def update(buffer: AggregationBuffer, input: InternalRow): Unit 
= {
    +    partial1ModeEvaluator.iterate(
    +      buffer, wrap(inputProjection(input), inputWrappers, cached, 
inputDataTypes))
    +  }
    +
    +  override def merge(buffer: AggregationBuffer, input: AggregationBuffer): 
Unit = {
    +    partial2ModeEvaluator.merge(buffer, 
partial1ModeEvaluator.terminatePartial(input))
    +  }
    +
    +  override def eval(buffer: AggregationBuffer): Any = {
    +    resultUnwrapper(finalModeEvaluator.terminate(buffer))
    +  }
    +
    +  override def serialize(buffer: AggregationBuffer): Array[Byte] = {
    +    aggBufferSerDe.serialize(buffer)
    +  }
    +
    +  override def deserialize(bytes: Array[Byte]): AggregationBuffer = {
    +    aggBufferSerDe.deserialize(bytes)
    +  }
    +
    +  // Helper class used to de/serialize Hive UDAF `AggregationBuffer` 
objects
    +  private class AggregationBufferSerDe {
    +    private val partialResultUnwrapper = 
unwrapperFor(partialResultInspector)
    +
    +    private val partialResultWrapper = wrapperFor(partialResultInspector, 
partialResultDataType)
    +
    +    private val projection = 
UnsafeProjection.create(Array(partialResultDataType))
    --- End diff --
    
    Can you try to run hive udaf in spark shell? IIUC, we can't create unsafe 
projection inside UDAF


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to