HyukjinKwon commented on code in PR #60542:
URL: https://github.com/apache/spark/pull/60542#discussion_r4581893811


##########
python/pyspark/sql/tests/arrow/test_arrow_python_aggregator.py:
##########
@@ -347,6 +348,44 @@ def test_pivot_rejected(self):
         with self.assertRaises(AnalysisException):
             df.groupBy("k").pivot("p").agg(udaf(Mean())(sf.col("v"))).collect()
 
+    def test_session_window_rejected(self):
+        # A batch session window groups by one provisional session per row and 
relies on the
+        # aggregate operator to merge the overlapping ones. The incremental 
operators do not
+        # merge sessions, so grouping by a session window is rejected rather 
than returning one
+        # row per unmerged session. A tumbling window needs no merging and 
still works.
+        df = self.spark.createDataFrame(
+            [
+                (datetime.datetime(2026, 1, 1, 10, 0), 1.0),
+                (datetime.datetime(2026, 1, 1, 10, 2), 3.0),
+            ],
+            "ts timestamp, v double",
+        )
+        mean = udaf(Mean())
+        df.createOrReplaceTempView("session_input")
+        self.spark.udf.register("session_mean", mean)
+        queries = {
+            "dataframe": lambda: df.groupBy(sf.session_window("ts", "5 
minutes")).agg(

Review Comment:
   Done in 1f3526b: `test_session_window` also groups by `"k", 
sf.session_window("ts", "5 minutes")`, and its SQL form groups by `k, 
session_window(ts, '5 minutes')`.



##########
common/utils/src/main/resources/error/error-conditions.json:
##########
@@ -9851,6 +9851,11 @@
           "Purge table."
         ]
       },
+      "PYTHON_AGGREGATOR_WITH_SESSION_WINDOW" : {
+        "message" : [
+          "The incremental Python aggregate function(s) <functionList> in an 
aggregation grouped by a session window."

Review Comment:
   1f3526b removes this error condition, since the sessions are now merged.



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