cloud-fan commented on a change in pull request #34352:
URL: https://github.com/apache/spark/pull/34352#discussion_r733473500



##########
File path: 
sql/core/src/main/scala/org/apache/spark/sql/internal/BaseSessionStateBuilder.scala
##########
@@ -410,6 +415,35 @@ class SparkUDFExpressionBuilder extends 
FunctionExpressionBuilder {
           name, expr.inputTypes.size.toString, input.size)
       }
       expr
+    } else if (classOf[Aggregator[_, _, _]].isAssignableFrom(clazz)) {
+      val aggregator = 
clazz.getConstructor().newInstance().asInstanceOf[Aggregator[Any, Any, Any]]
+
+      // Construct the input encoder
+      val mirror = universe.runtimeMirror(clazz.getClassLoader)
+      val classType = mirror.classSymbol(clazz)
+      val baseClassType = universe.typeOf[Aggregator[_, _, 
_]].typeSymbol.asClass
+      val baseType = 
universe.internal.thisType(classType).baseType(baseClassType)
+      val tpe = baseType.typeArgs.head
+      val cls = mirror.runtimeClass(tpe)
+      val serializer = ScalaReflection.serializerForType(tpe)
+      val deserializer = ScalaReflection.deserializerForType(tpe)
+      val inputEncoder = new ExpressionEncoder[Any](
+        serializer,
+        deserializer,
+        ClassTag(cls))

Review comment:
       ```suggestion
         val inputEncoder = new ExpressionEncoder[Any](serializer, 
deserializer, ClassTag(cls))
   ```




-- 
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]

Reply via email to