Add WHEN NOT MATCHED BY SOURCE support #1511
Closed
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.
Description
Add
WHEN NOT MATCHED BY SOURCE
to MergeIntoCommandThis PR adds support for
WHEN NOT MATCHED BY SOURCE
clauses in merge into command using the Scala/Java Delta table API. Support forWHEN NOT MATCHED BY SOURCE
using SQL will be available with Spark 3.4 release and python support will follow up in a different PR.Changes:
NOT MATCHED BY SOURCE
clause.NOT MATCHED BY SOURCE
conditions and update actionsMATCHED
clause): generate update expressions to align with the expected target schemaNOT MATCHED BY SOURCE
in MergeIntoCommand.How was this patch tested?
New test trait
MergeIntoNotMatchedBySourceSuite
is added and collects all tests covering this feature. It is mixed into the Merge Scala test class to run tests against the Delta API and will be mixed in the Merge base test class to also cover the Spark SQL API once Spark 3.4 is released.Test coverage:
Does this PR introduce any user-facing changes?
This change extends the existing Delta Merge API to allow specifying
WHEN NOT MATCHED BY SOURCE
clauses and their corresponding optional condition and actions. The new API follows the existing APIs forMATCHED
andNOT MATCHED
clauses.Usage - Scala: