You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by yi...@apache.org on 2026/10/01 17:08:18 UTC
(spark) branch branch-4.3 updated: [SPARK-58601][PYTHON][TEST][FOLLOWUP] Cover the mapInBatch acceptAnyIterable default in mapInArrow/mapInPandas
This is an automated email from the ASF dual-hosted git repository.
Yicong-Huang pushed a commit to branch branch-4.3
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/branch-4.3 by this push:
new e4e57ed064b0 [SPARK-58601][PYTHON][TEST][FOLLOWUP] Cover the mapInBatch acceptAnyIterable default in mapInArrow/mapInPandas
e4e57ed064b0 is described below
commit e4e57ed064b04473ac259087648ca2afa339f823
Author: Yicong Huang <17...@users.noreply.github.com>
AuthorDate: Thu Oct 1 17:05:45 2026 +0000
[SPARK-58601][PYTHON][TEST][FOLLOWUP] Cover the mapInBatch acceptAnyIterable default in mapInArrow/mapInPandas
### What changes were proposed in this pull request?
Add positive tests for `mapInArrow` and `mapInPandas` that return a non-`Iterator` iterable (a `list`) *without* setting `spark.sql.execution.pythonUDF.mapInBatch.legacy.acceptAnyIterable.enabled`, asserting the value is accepted under the config's default. The tests are added to the shared `MapInArrowTestsMixin` / `MapInPandasTestsMixin`, so they run in both the classic and Spark Connect suites.
### Why are the changes needed?
The follow-up #58436 flipped `spark.sql.execution.pythonUDF.mapInBatch.legacy.acceptAnyIterable.enabled` to default `true`, restoring the pre-4.3.0 lenient behavior where a `mapInPandas`/`mapInArrow` UDF may return any iterable. The existing `*_legacy_accept_any_iterable` tests set that flag to `true` explicitly, so they would still pass if the default were flipped back to `false` and therefore do not protect the default from regression. A test that relies on the default (sets no conf [...]
### Does this PR introduce _any_ user-facing change?
No. Test-only.
### How was this patch tested?
New tests pass in both classic and Spark Connect modes for `mapInArrow` and `mapInPandas`:
```
python/run-tests --testnames \
"pyspark.sql.tests.arrow.test_arrow_map MapInArrowTests.test_map_in_arrow_accept_any_iterable_by_default,\
pyspark.sql.tests.pandas.test_pandas_map MapInPandasTests.test_map_in_pandas_accept_any_iterable_by_default,\
pyspark.sql.tests.connect.arrow.test_parity_arrow_map ArrowMapParityTests.test_map_in_arrow_accept_any_iterable_by_default,\
pyspark.sql.tests.connect.pandas.test_parity_pandas_map MapInPandasParityTests.test_map_in_pandas_accept_any_iterable_by_default"
```
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Claude Opus 4.8)
This pull request and its description were written by Isaac.
Closes #59168 from Yicong-Huang/mapinbatch-default-tests.
Authored-by: Yicong Huang <17...@users.noreply.github.com>
Signed-off-by: Yicong-Huang <17...@users.noreply.github.com>
(cherry picked from commit a363a856de83c58074b8534e2ff743d4e6664c9e)
Signed-off-by: Yicong-Huang <17...@users.noreply.github.com>
---
python/pyspark/sql/tests/arrow/test_arrow_map.py | 13 +++++++++++++
python/pyspark/sql/tests/pandas/test_pandas_map.py | 10 ++++++++++
2 files changed, 23 insertions(+)
diff --git a/python/pyspark/sql/tests/arrow/test_arrow_map.py b/python/pyspark/sql/tests/arrow/test_arrow_map.py
index 2c93baa54c59..0d42e31edfda 100644
--- a/python/pyspark/sql/tests/arrow/test_arrow_map.py
+++ b/python/pyspark/sql/tests/arrow/test_arrow_map.py
@@ -92,6 +92,19 @@ class MapInArrowTestsMixin:
expected = df.collect()
self.assertEqual(actual, expected)
+ def test_map_in_arrow_accept_any_iterable_by_default(self):
+ # The legacy flag defaults to true, so returning a non-Iterator iterable (e.g. list) is
+ # accepted without setting any config. This guards the default against regression: the
+ # *_legacy_accept_any_iterable tests above force the flag on and would still pass if the
+ # default were flipped back to false.
+ def list_not_iter(iterator):
+ return [batch for batch in iterator]
+
+ df = self.spark.range(10)
+ actual = df.mapInArrow(list_not_iter, "id long").collect()
+ expected = df.collect()
+ self.assertEqual(actual, expected)
+
def test_map_in_arrow_with_limit(self):
def get_size(iterator):
for batch in iterator:
diff --git a/python/pyspark/sql/tests/pandas/test_pandas_map.py b/python/pyspark/sql/tests/pandas/test_pandas_map.py
index d31b575a34f9..b1ea79c0c8c1 100644
--- a/python/pyspark/sql/tests/pandas/test_pandas_map.py
+++ b/python/pyspark/sql/tests/pandas/test_pandas_map.py
@@ -120,6 +120,16 @@ class MapInPandasTestsMixin:
expected = df.collect()
self.assertEqual(actual, expected)
+ def test_map_in_pandas_accept_any_iterable_by_default(self):
+ # The legacy flag defaults to true, so returning a non-Iterator iterable (e.g. list) is
+ # accepted without setting any config. This guards the default against regression: the
+ # *_legacy_accept_any_iterable tests above force the flag on and would still pass if the
+ # default were flipped back to false.
+ df = self.spark.range(10, numPartitions=3)
+ actual = df.mapInPandas(lambda it: [pdf for pdf in it], "id long").collect()
+ expected = df.collect()
+ self.assertEqual(actual, expected)
+
def test_multiple_columns(self):
data = [(1, "foo"), (2, None), (3, "bar"), (4, "bar")]
df = self.spark.createDataFrame(data, "a int, b string")
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org