GitHub user gatorsmile opened a pull request:
https://github.com/apache/spark/pull/14612
[SPARK-16803] [SQL] SaveAsTable does not work when source DataFrame is
built on a Hive Table
### What changes were proposed in this pull request?
In Spark 2.0, `SaveAsTable` does not work when source DataFrame is built on
a Hive Table, but Spark 1.6 works.
**Spark 1.6**
```Scala
scala> sql("create table sample.sample stored as SEQUENCEFILE as select 1
as key, 'abc' as value")
res2: org.apache.spark.sql.DataFrame = []
scala> val df = sql("select key, value as value from sample.sample")
df: org.apache.spark.sql.DataFrame = [key: int, value: string]
scala> df.write.mode("append").saveAsTable("sample.sample")
scala> sql("select * from sample.sample").show()
+---+-----+
|key|value|
+---+-----+
| 1| abc|
| 1| abc|
+---+-----+
```
**Spark 2.0**
```Scala
scala> df.write.mode("append").saveAsTable("sample.sample")
org.apache.spark.sql.AnalysisException: Saving data in MetastoreRelation
sample, sample
is not supported.;
```
This PR is to provide a support with by-name resolution. In 1.6, it is
by-position resolution. The previous behavior is wrong. We need to adjust the
order.
### How was this patch tested?
Test cases are added
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/gatorsmile/spark saveAsTableFix2
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/14612.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 #14612
----
commit 1967fcbeb6c7934e825cb9c043e6aa04bb057fc1
Author: gatorsmile <[email protected]>
Date: 2016-08-11T23:04:43Z
fix.
commit 1d3d392f2c6bbd358b55f3bde12806e2979dfa01
Author: gatorsmile <[email protected]>
Date: 2016-08-11T23:08:57Z
improve the comment
----
---
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]