-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[spark] Eliminate the union stage when merging into with out notMatch… #5137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
d96867c to
a4fdf0b
Compare
|
before: after: |
| } | ||
| } | ||
| if (hasUpdate(matchedActions)) { | ||
| if (hasUpdate(matchedActions) || notMatchedActions.nonEmpty) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain this line in detail?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when there is matched or not matched action by target, we should evaluate on the file splits after inner join. Otherwise, all the source rows are not matched by target.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the test of this could verify this.
test(s"Paimon MergeInto: only insert") {
withTable("source", "target") {
Seq((1, 100, "c11"), (3, 300, "c33")).toDF("a", "b", "c").createOrReplaceTempView("source")
createTable("target", "a INT, b INT, c STRING", Seq("a"))
spark.sql("INSERT INTO target values (1, 10, 'c1'), (2, 20, 'c2')")
spark.sql(s"""
|MERGE INTO target
|USING source
|ON target.a = source.a
|WHEN NOT MATCHED
|THEN INSERT (a, b, c) values (a, b, c)
|""".stripMargin)
checkAnswer(
spark.sql("SELECT * FROM target ORDER BY a, b"),
Row(1, 10, "c1") :: Row(2, 20, "c2") :: Row(3, 300, "c33") :: Nil)
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @YannByron , I have another thought for this question, and opened another PR
I think we should not use this condition to move this untouched files into touched file set, which will increase the rewrite input/output size.
Instead, if not matched action is non empty, these files should be input as untouched files, and we only have to consume the untouched files only when the not matched by target action is present
…edBySource
Purpose
Linked issue: close #5136
Tests
API and Format
Documentation