[SPARK-56757][PYTHON] Refactor scalar iterator Pandas UDF worker path#55755
Open
201573 wants to merge 1 commit intoapache:masterfrom
Open
[SPARK-56757][PYTHON] Refactor scalar iterator Pandas UDF worker path#55755201573 wants to merge 1 commit intoapache:masterfrom
201573 wants to merge 1 commit intoapache:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
This PR refactors
SQL_SCALAR_PANDAS_ITER_UDFso that the scalar iterator Pandas UDF logic is handled insideread_udfs().The worker now uses
ArrowStreamSerializerfor the scalar iterator Pandas UDF I/O path, converts input Arrow batches to pandas arguments inread_udfs(), validates the iterator and element return types there, and converts the pandas outputs back to Arrow record batches.This keeps the existing row-count checks and return validation while making the serializer a pure Arrow I/O layer for this eval type.
Why are the changes needed?
This is part of SPARK-55388. The scalar iterator Pandas UDF path should be self-contained in
read_udfs()instead of relying onArrowStreamPandasUDFSerializerto perform UDF-specific logic.Does this PR introduce any user-facing change?
No.
How was this patch tested?
Added a test for scalar iterator Pandas UDFs with struct input and struct output.
Verified locally:
SPARK_HOME=/tmp/spark-56757-wt PYTHON_EXECUTABLE=/tmp/spark-venv-56757/bin/python ./python/run-tests --python-executables /tmp/spark-venv-56757/bin/python --testnames 'pyspark.sql.tests.pandas.test_pandas_udf_scalar ScalarPandasUDFTests.test_scalar_iter_udf_struct_input_and_output' -p 1SPARK_HOME=/tmp/spark-56757-wt PYTHON_EXECUTABLE=/tmp/spark-venv-56757/bin/python ./python/run-tests --python-executables /tmp/spark-venv-56757/bin/python --testnames 'pyspark.sql.tests.pandas.test_pandas_udf_scalar ScalarPandasUDFTests.test_vectorized_udf_invalid_length,pyspark.sql.tests.pandas.test_pandas_udf_scalar ScalarPandasUDFTests.test_vectorized_udf_chained_struct_type,pyspark.sql.tests.pandas.test_pandas_udf_scalar ScalarPandasUDFTests.test_scalar_iter_pandas_udf_with_single_output_batch' -p 1PYTHON_EXECUTABLE=/tmp/spark-venv-56757/bin/python ./dev/lint-python --compile/tmp/spark-venv-56757/bin/ruff format --check python/pyspark/worker.py python/pyspark/sql/tests/pandas/test_pandas_udf_scalar.py/tmp/spark-venv-56757/bin/ruff check python/pyspark/worker.py python/pyspark/sql/tests/pandas/test_pandas_udf_scalar.pygit diff --checkWas this patch authored or co-authored using generative AI tooling?
Generated-by: OpenAI Codex (GPT-5)