HyukjinKwon commented on a change in pull request #25215:
[SPARK-28445][SQL][Python] Fix error when PythonUDF is used in both group by
and aggregate expression
URL: https://github.com/apache/spark/pull/25215#discussion_r305649625
##########
File path: sql/core/src/test/scala/org/apache/spark/sql/DataFrameSuite.scala
##########
@@ -2189,4 +2189,46 @@ class DataFrameSuite extends QueryTest with
SharedSQLContext {
|*(1) Range (0, 10, step=1, splits=2)""".stripMargin))
}
}
+
+ test("SPARK-28445: PythonUDF in grouping key and aggregate expressions") {
+ import IntegratedUDFTestUtils._
+
+ val scalaTestUDF = TestScalaUDF(name = "scalaUDF")
+ registerTestUDF(scalaTestUDF, spark)
+
+ val pythonTestUDF = TestPythonUDF(name = "pyUDF")
+ registerTestUDF(pythonTestUDF, spark)
+
+ withTempView("testData") {
+ sql(
+ """CREATE OR REPLACE TEMPORARY VIEW testData AS
+ |SELECT * FROM VALUES
+ |(1, 1), (1, 2), (2, 1), (2, 2), (3, 1), (3, 2), (null, 1), (3,
null), (null, null)
+ |AS testData(a, b)""".stripMargin)
+
+ val df = sql("SELECT scalaUDF(a + 1), scalaUDF(COUNT(b)) FROM testData "
+
Review comment:
@viirya is it possible to write those tests by Scala DSL instead of SQL?
----------------------------------------------------------------
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]