Repository navigation
[SPARK-61146][CONNECT][PYTHON] Create DataFrames of pandas frames whose struct fields repeat names in the Python client, as PySpark does - #345
Closed
HyukjinKwon wants to merge 1 commit into
Conversation
…se struct fields repeat names in the Python client, as PySpark does PySpark Connect converts a pandas frame under a struct schema with the deduplicated names of _deduplicate_field_names (x_0, x_1 for struct<x: string, x: int>), and sends that Arrow table with the schema as given, which the server applies. The client converted it the same way, but then normalized the table again as an Arrow table of the caller, which raised DUPLICATED_FIELD_NAME_IN_ARROW_STRUCT. It now sends the converted table with the schema, as PySpark Connect does. Co-authored-by: Isaac <no-reply@databricks.com>
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?
SPARK-61146: PySpark Connect's
createDataFrameof a pandas DataFrame under a struct schema whose structs repeat field names, such asstruct<x: string, x: int>:_deduplicate_field_names(x_0,x_1)The client converted the frame the same way, in
prepare_pandas_table. But it then normalized the table again as an Arrow table of the caller (prepare_table), which may not repeat the field names of a struct. It now sends the converted table with the schema, as PySpark Connect does.The second normalization changed nothing else for this table. Its types are already those of the schema, and its timestamps are already of UTC. It also fetched the Arrow input settings a second time, so
createDataFrameof such a frame now sends oneConfigrequest fewer (integer_tuple_cases.pycounts them).Why are the changes needed?
The client raised:
Apache Spark's
test_createDataFrame_pandas_duplicate_field_namesoftest_parity_arrow.pyfailed on this client.Does this PR introduce any user-facing change?
Yes. A pandas frame under a schema whose structs repeat field names becomes a DataFrame, as with PySpark 4.3.0.
How was this patch tested?
wasm-udf, the offline Python suites (2205 passed, 8 skipped), and the live drop-in and Arrow suites (188 passed) and live cases (10 passed) against a local Spark 4.3.0 server. Clippy reports no diagnostics in the changed lines.Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Opus 5.5
This pull request and its description were written by Isaac.