Uh oh!
There was an error while loading. Please reload this page.
[SPARK-28411][PYTHON][SQL] InsertInto with overwrite is not honored - #25175
Closed
huaxingao wants to merge 4 commits into
Closed
[SPARK-28411][PYTHON][SQL] InsertInto with overwrite is not honored#25175huaxingao wants to merge 4 commits into
huaxingao wants to merge 4 commits into
Conversation
SparkQA
commented
Jul 16, 2019
Test build #107763 has finished for PR 25175 at commit
|
| """ | ||
| self._jwrite.mode("overwrite" if overwrite else "append").insertInto(tableName) | ||
| if (overwrite): | ||
| self._jwrite.mode("overwrite") |
Member
There was a problem hiding this comment.
Can we call self.mode("overwrite") instead?
| Optionally overwriting any existing data. | ||
| """ | ||
| self._jwrite.mode("overwrite" if overwrite else "append").insertInto(tableName) | ||
| if (overwrite): |
| def test_insert_into(self): | ||
| df = self.spark.createDataFrame([("a", 1), ("b", 2)], ["C1", "C2"]) | ||
| df.write.saveAsTable("test_table") |
Member
There was a problem hiding this comment.
Can you use with self.table("test_table"): too?
| df.write.insertInto("test_table", False) | ||
| self.assertEqual(4, self.spark.sql("select * from test_table").count()) | ||
| # self.spark.sql("drop table test_table") |
SparkQA
commented
Jul 17, 2019
Test build #107771 has finished for PR 25175 at commit
|
SparkQA
commented
Jul 17, 2019
Test build #107774 has finished for PR 25175 at commit
|
ueshin
commented
Jul 17, 2019
Member
I'm wondering what if a user explicitly specifies df.write.mode("overwrite").insertInto("table", overwrite=False)It might be better that the default value for cc @HyukjinKwon |
HyukjinKwon
commented
Jul 17, 2019
Member
Yup, that's fine with me too. |
SparkQA
commented
Jul 17, 2019
Test build #107793 has finished for PR 25175 at commit
|
HyukjinKwon
commented
Jul 18, 2019
Member
Merged to master. |
vinodkc pushed a commit
to vinodkc/spark
that referenced
this pull request
Jul 18, 2019
## What changes were proposed in this pull request?
In the following python code
```
df.write.mode("overwrite").insertInto("table")
```
```insertInto``` ignores ```mode("overwrite")``` and appends by default.
## How was this patch tested?
Add Unit test.
Closesapache#25175 from huaxingao/spark-28411.
Authored-by: Huaxin Gao <huaxing@us.ibm.com>
Signed-off-by: HyukjinKwon <gurwls223@apache.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
In the following python code
insertIntoignoresmode("overwrite")and appends by default.How was this patch tested?
Add Unit test.