GitHub user gatorsmile opened a pull request:
https://github.com/apache/spark/pull/18386
[SPARK-21165] [SQL] [2.2] Use executedPlan instead of analyzedPlan
### What changes were proposed in this pull request?
The input query schema of INSERT AS SELECT could be changed after
optimization. For example, the following query's output schema is changed by
the rule `SimplifyCasts`.
```SQL
SELECT word, length, cast(first as string) as first FROM view1
```
This PR is to fix the issue in Spark 2.2. Instead of using the analyzed
plan of the input query, this PR use its executed plan to determine the
attributes in `FileFormatWriter`.
The related issue in the master branch has been fixed by
https://github.com/apache/spark/pull/18064. After this PR is merged, I will
submit a separate PR to merge the test case to the master.
### How was this patch tested?
Added a test case
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/gatorsmile/spark newRC5
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/18386.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 #18386
----
commit 86ac97533fdcb524d9337a6ef31f395391b57ec3
Author: Xiao Li <[email protected]>
Date: 2017-06-22T06:18:54Z
fix.
----
---
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]