GitHub user liancheng opened a pull request:
https://github.com/apache/spark/pull/12952
[SPARK-15112][SQL] Allows query plan schema and encoder schema of a Dataset
have different column order
## What changes were proposed in this pull request?
This PR fixes two issues that cause the data corruption bug in
[SPARK-15112][1]:
1. `Dataset.schema` should comform to `Dataset.resolvedTEncoder.schema`
rather than the schema of the underlying logical plan
An `ExpressionEncoder` doesn't require input column order to be the same
as column order of its own schema. Essentially, it performs a projection to
adjust column order at runtime. This is particularly useful for data sources
that support schema evolution, in which cases column order of the merged result
schema can be non-deterministic.
Please refer to [this JIRA comment][2] for more details.
2. Optimization rule `EmbedSerializerInFilter` may produce wrong output
column order.
This PR fixes this issue by adding a `Project` to adjust output column
order when necessary.
Please refer to [this JIRA comment][3] for more details.
## How was this patch tested?
A regression test case is added to `DatasetSuite`.
[1]: https://issues.apache.org/jira/browse/SPARK-15112
[2]:
https://issues.apache.org/jira/browse/SPARK-15112?focusedCommentId=15271025&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-15271025
[3]:
https://issues.apache.org/jira/browse/SPARK-15112?focusedCommentId=15273837&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-15273837
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/liancheng/spark
spark-15112-dataset-input-column-order
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/12952.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 #12952
----
commit 4ff62e09547d0902b9bb72ddb630a2fb566a8cb3
Author: Cheng Lian <[email protected]>
Date: 2016-05-06T09:18:45Z
Fixes SPARK-15112
----
---
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]