beliefer commented on a change in pull request #34303:
URL: https://github.com/apache/spark/pull/34303#discussion_r730555343



##########
File path: 
sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveSQLViewSuite.scala
##########
@@ -179,4 +181,24 @@ class HiveSQLViewSuite extends SQLViewSuite with 
TestHiveSingleton {
       }
     }
   }
+
+  test("SPARK-37018: Spark SQL should support create function with 
Aggregator") {
+    val avgFuncClass = "org.apache.spark.sql.hive.execution.MyDoubleAverage"
+    val functionName = "test_udf"
+    withTempDatabase { dbName =>
+      withUserDefinedFunction(
+        s"default.$functionName" -> false,
+        s"$dbName.$functionName" -> false,
+        functionName -> true) {
+        // create a function in default database
+        sql("USE DEFAULT")
+        sql(s"CREATE FUNCTION $functionName AS '$avgFuncClass'")
+        // create a view using a function in 'default' database
+        withView("v1") {
+          sql(s"CREATE VIEW v1 AS SELECT $functionName(col1) AS func FROM 
VALUES (1), (2), (3)")
+          checkAnswer(sql(s"SELECT * FROM v1"), Seq(Row(102.0)))

Review comment:
       Thanks.




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