GitHub user ueshin opened a pull request:
https://github.com/apache/spark/pull/13090
[SPARK-15308][SQL] RowEncoder should preserve nested column name.
## What changes were proposed in this pull request?
The following code generates wrong schema:
```
val schema = new StructType().add(
"struct",
new StructType()
.add("i", IntegerType, nullable = false)
.add(
"s",
new StructType().add("int", IntegerType, nullable = false),
nullable = false),
nullable = false)
val ds = sqlContext.range(10).map(l => Row(l, Row(l)))(RowEncoder(schema))
ds.printSchema()
```
This should print as follows:
```
root
|-- struct: struct (nullable = false)
| |-- i: integer (nullable = false)
| |-- s: struct (nullable = false)
| | |-- int: integer (nullable = false)
```
but the result is:
```
|-- struct: struct (nullable = false)
| |-- col1: integer (nullable = false)
| |-- col2: struct (nullable = false)
| | |-- col1: integer (nullable = false)
```
This PR fixes `RowEncoder` to preserve nested column name.
## How was this patch tested?
Existing tests and I added a test to check if `RowEncoder` preserves nested
column name.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/ueshin/apache-spark issues/SPARK-15308
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/13090.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #13090
----
commit d4ae79775f2ba0ebd0dd65b52076930244c2be96
Author: Takuya UESHIN <[email protected]>
Date: 2016-05-13T04:02:41Z
Add a test to check if RowEncoder preserves nested column name.
commit ddb9ce6692d9b70b7656196191d3572696ee0a12
Author: Takuya UESHIN <[email protected]>
Date: 2016-05-13T04:08:00Z
Fix RowEncoder to preserve nested column name.
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]