HyukjinKwon commented on a change in pull request #25352:
[SPARK-28422][SQL][Python] GROUPED_AGG pandas_udf should work without group by
clause
URL: https://github.com/apache/spark/pull/25352#discussion_r313466840
##########
File path: python/pyspark/sql/tests/test_pandas_udf_grouped_agg.py
##########
@@ -474,6 +474,21 @@ def test_grouped_with_empty_partition(self):
result = df.groupBy('id').agg(f(df['x']).alias('sum')).collect()
self.assertEqual(result, expected)
+ def test_grouped_without_group_by_clause(self):
+ @pandas_udf('double', PandasUDFType.GROUPED_AGG)
+ def max_udf(v):
+ return v.max()
+
+ df = self.spark.range(0, 100)
+ self.spark.udf.register('max_udf', max_udf)
+
+ with self.tempView("table"):
+ df.createTempView('table')
+
+ agg1 = df.agg(max_udf(df['id']))
+ agg2 = self.spark.sql("select max_udf(id) from table")
+ assert_frame_equal(agg1.toPandas(), agg2.toPandas())
Review comment:
nit: we can just collect and compare the value without `toPandas` but not a
bit deal.
----------------------------------------------------------------
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]