[SPARK-56612][PYTHON] Unify verify_result and container-type checks into verify_return_type helper#55532
Open
Yicong-Huang wants to merge 12 commits intoapache:masterfrom
Open
[SPARK-56612][PYTHON] Unify verify_result and container-type checks into verify_return_type helper#55532Yicong-Huang wants to merge 12 commits intoapache:masterfrom
Yicong-Huang wants to merge 12 commits intoapache:masterfrom
Conversation
Contributor
Author
|
@gaogaotiantian please kindly share your thoughts! |
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?
Introduce
verify_return_type(result, expected_type)inworker.py:pa.Table) —isinstancecheck, returnresult.Iterator[T]— checkresultis anIterator, return a lazy iterator that checks each element againstTon consumption.Apply it to:
SQL_MAP_ARROW_ITER_UDFandSQL_SCALAR_ARROW_ITER_UDF(replacing the oldverify_resultfactory).verify_arrow_table/verify_arrow_batch— inlined at their 3 call sites and removed.Runtime now strictly requires an
Iterator(was: any iterable), matching the declared contractArrowMapIterFunction = Callable[[Iterator[...]], Iterator[...]]and the_name == "Iterator"convention inpyspark/sql/pandas/typehints.py.Why are the changes needed?
Part of SPARK-55388. One well-named helper unifies the iterator factory and scattered inline
isinstancechecks, enabling further eval-type refactors.Does this PR introduce any user-facing change?
No. Minor tightening: a UDF returning a non-
Iteratoriterable (e.g.list) is now rejected withUDF_RETURN_TYPE, aligning runtime with the documentedIterator[...]signatures.How was this patch tested?
Existing integration coverage:
test_arrow_map.py::test_other_than_recordbatch_iterexercises the iterator path; other verify_arrow_* callers (mapInArrow, grouped-map Arrow UDFs) exercise the concrete-type path.Was this patch authored or co-authored using generative AI tooling?
No