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_r305661269
 
 

 ##########
 File path: sql/core/src/test/scala/org/apache/spark/sql/DataFrameSuite.scala
 ##########
 @@ -2189,4 +2189,50 @@ 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")
+    val pythonTestUDF = TestPythonUDF(name = "pyUDF")
+    assume(shouldTestPythonUDFs)
+
+    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 base = spark.table("testData")
 
 Review comment:
   Ah, I would just use DSL here too although it's a bit ugly to handle `null`s.
   
   ```scala
   val base = Seq(
     (Some(1), Some(1)), (Some(1), Some(2)), (Some(2), Some(1)),
     (Some(2), Some(2)), (Some(3), Some(1)), (Some(3), Some(2)),
     (None, Some(1)), (Some(3), None), (None, None)).toDF("a", "b")
   ```

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

Reply via email to