beliefer opened a new pull request, #39514:
URL: https://github.com/apache/spark/pull/39514
### What changes were proposed in this pull request?
Currently, Connect API createDataFrame does not support create dataframe
with map type.
For example,
```
>>> df = spark.createDataFrame(
... [(1, ["foo", "bar"], {"x": 1.0}), (2, [], {}), (3, None, None)],
... ("id", "an_array", "a_map")
... )
```
The above code want create a dataframe with column 'a_map' which is map type.
But pyarrow recognize {"x": 1.0} as a struct not map.
pyarrow supports map with format [('x', 1.0)]
Because the data frame's schema is not correct, so the other sequence
operator will be impacted.
For example:
`df.select("id", "a_map", posexplode_outer("an_array")).show()`
Expected:
```
+---+----------+----+----+
| id| a_map| pos| col|
+---+----------+----+----+
| 1|{x -> 1.0}| 0| foo|
| 1|{x -> 1.0}| 1| bar|
| 2| {}|null|null|
| 3| null|null|null|
+---+----------+----+----+
```
But got:
```
+---+------+----+----+
| id| a_map| pos| col|
+---+------+----+----+
| 1| {1.0}| 0| foo|
| 1| {1.0}| 1| bar|
| 2|{null}|null|null|
| 3| null|null|null|
+---+------+----+----+
<BLANKLINE>
```
### Why are the changes needed?
Let createDataFrame supports column with map type and fix some bugs.
### Does this PR introduce _any_ user-facing change?
'No'.
New feature.
### How was this patch tested?
Manual test and doc 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]