zhengruifeng opened a new pull request, #42970:
URL: https://github.com/apache/spark/pull/42970
### What changes were proposed in this pull request?
Refactor `test_mode` to be compatible with Spark Connect
### Why are the changes needed?
for test parity
### Does this PR introduce _any_ user-facing change?
No, test-only
### How was this patch tested?
CI, and manually check:
```
In [5]: import pandas as pd
In [6]: def func(iterator):
...: for pdf in iterator:
...: if len(pdf) > 0:
...: if pdf["partition"][0] == 3:
...: yield pd.DataFrame({"num" : ["0", "1", "2",
"3", "4"] })
...: else:
...: yield pd.DataFrame({"num" : ["3", "3", "3",
"3", "4"]} )
...:
In [7]: df = spark.range(0, 4, 1,
4).select(sf.spark_partition_id().alias("partition"))
In [8]: df.mapInPandas(func, "num string").withColumn("p",
sf.spark_partition_id()).show()
/Users/ruifeng.zheng/Dev/spark/python/lib/pyspark.zip/pyspark/sql/pandas/serializers.py:239:
FutureWarning: is_categorical_dtype is deprecated and will be removed in a
future version. Use isinstance(dtype, CategoricalDtype) instead
/Users/ruifeng.zheng/Dev/spark/python/lib/pyspark.zip/pyspark/sql/pandas/serializers.py:239:
FutureWarning: is_categorical_dtype is deprecated and will be removed in a
future version. Use isinstance(dtype, CategoricalDtype) instead
/Users/ruifeng.zheng/Dev/spark/python/lib/pyspark.zip/pyspark/sql/pandas/serializers.py:239:
FutureWarning: is_categorical_dtype is deprecated and will be removed in a
future version. Use isinstance(dtype, CategoricalDtype) instead
/Users/ruifeng.zheng/Dev/spark/python/lib/pyspark.zip/pyspark/sql/pandas/serializers.py:239:
FutureWarning: is_categorical_dtype is deprecated and will be removed in a
future version. Use isinstance(dtype, CategoricalDtype) instead
+---+---+
|num| p|
+---+---+
| 3| 0|
| 3| 0|
| 3| 0|
| 3| 0|
| 4| 0|
| 3| 1|
| 3| 1|
| 3| 1|
| 3| 1|
| 4| 1|
| 3| 2|
| 3| 2|
| 3| 2|
| 3| 2|
| 4| 2|
| 0| 3|
| 1| 3|
| 2| 3|
| 3| 3|
| 4| 3|
+---+---+
```
### Was this patch authored or co-authored using generative AI tooling?
No
--
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]