dtenedor commented on code in PR #42663:
URL: https://github.com/apache/spark/pull/42663#discussion_r1310564760


##########
python/pyspark/sql/tests/pandas/test_pandas_udf_grouped_agg.py:
##########
@@ -575,6 +575,128 @@ def mean(x):
 
         assert filtered.collect()[0]["mean"] == 42.0
 
+    def test_named_arguments(self):
+        df = self.data
+        weighted_mean = self.pandas_agg_weighted_mean_udf
+
+        with self.tempView("v"):
+            df.createOrReplaceTempView("v")
+            self.spark.udf.register("weighted_mean", weighted_mean)
+
+            for i, aggregated in enumerate(
+                [
+                    df.groupby("id").agg(weighted_mean(df.v, 
w=df.w).alias("wm")),
+                    df.groupby("id").agg(weighted_mean(v=df.v, 
w=df.w).alias("wm")),
+                    df.groupby("id").agg(weighted_mean(w=df.w, 
v=df.v).alias("wm")),
+                    self.spark.sql("SELECT id, weighted_mean(v, w => w) as wm 
FROM v GROUP BY id"),
+                    self.spark.sql(
+                        "SELECT id, weighted_mean(v => v, w => w) as wm FROM v 
GROUP BY id"
+                    ),
+                    self.spark.sql(
+                        "SELECT id, weighted_mean(w => w, v => v) as wm FROM v 
GROUP BY id"
+                    ),
+                ]
+            ):
+                with self.subTest(query_no=i):
+                    assertDataFrameEqual(aggregated, 
df.groupby("id").agg(mean(df.v).alias("wm")))
+
+    def test_named_arguments_negative(self):

Review Comment:
   can you please also port these negative tests to the 'kwargs' Pandas UDF 
case as well? It would be good to make sure we do the same checks there. Same 
for the window functions testing.



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