GitHub user gatorsmile opened a pull request:
https://github.com/apache/spark/pull/18050
[SPARK-20831] [SQL] Fix INSERT OVERWRITE data source tables with IF NOT
EXISTS
### What changes were proposed in this pull request?
Currently, we have a bug when we specify `IF NOT EXISTS` in `INSERT
OVERWRITE` data source tables. For example, given a query:
```SQL
INSERT OVERWRITE TABLE $tableName partition (b=2, c=3) IF NOT EXISTS SELECT
9, 10
```
we will get the following error:
```
unresolved operator 'InsertIntoTable Relation[a#425,d#426,b#427,c#428]
parquet, Map(b -> Some(2), c -> Some(3)), true, true;;
'InsertIntoTable Relation[a#425,d#426,b#427,c#428] parquet, Map(b ->
Some(2), c -> Some(3)), true, true
+- Project [cast(9#423 as int) AS a#429, cast(10#424 as int) AS d#430]
+- Project [9 AS 9#423, 10 AS 10#424]
+- OneRowRelation$
```
This PR is to fix the issue to follow the behavior of Hive serde tables
> INSERT OVERWRITE will overwrite any existing data in the table or
partition unless IF NOT EXISTS is provided for a partition
### How was this patch tested?
Modified an existing test case
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/gatorsmile/spark insertPartitionIfNotExists
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/18050.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 #18050
----
commit 23b5ef5e1424dda7f3b19d7a987fe80f9faee533
Author: gatorsmile <[email protected]>
Date: 2017-05-21T18:18:25Z
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]