ueshin opened a new pull request, #40692:
URL: https://github.com/apache/spark/pull/40692
### What changes were proposed in this pull request?
Supports duplicated nested field names when `spark.createDataFrame` or
`df.collect`.
### Why are the changes needed?
If there are duplicated nested field names, the following error is raised:
```py
>>> from pyspark.sql.types import *
>>>
>>> data = [Row(Row("a", 1), Row(2, 3, "b", 4, "c")), Row(Row("x", 6),
Row(7, 8, "y", 9, "z"))]
>>> schema = (
... StructType()
... .add("struct", StructType().add("x", StringType()).add("x",
IntegerType()))
... .add(
... "struct",
... StructType()
... .add("a", IntegerType())
... .add("x", IntegerType())
... .add("x", StringType())
... .add("y", IntegerType())
... .add("y", StringType()),
... )
... )
>>> df = spark.createDataFrame(data, schema=schema)
Traceback (most recent call last):
...
pyarrow.lib.ArrowTypeError: Expected bytes, got a 'int' object
```
### Does this PR introduce _any_ user-facing change?
The duplicated nested field names will be available.
### How was this patch tested?
Added a test.
--
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]