[Kernel] Support column mapping mode in REPLACE TABLE including with fieldId re-use #4518
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.
Which Delta project/connector is this regarding?
Description
PR#1 here #4520 separates some of this out.
This PR re-enables support for column mapping tables with REPLACE, and allows fieldId re-use when the type/nullability is compatible. To check for this compatibility we essentially re-use our schema evolution code. Valid schema transformations in the normal case should also be valid changes when reusing fieldIds across REPLACE. Any fields in the replaceSchema that are not reusing existing fieldIds will be treated as new fields during the schema evolution validation.
This validation checks that nullability changes are valid (cannot change from nullable to non-nullable) and that type changes are valid (for now, cannot change types). Columns are able to be moved (or nested columns dropped) if the other invariants hold.
Note, this currently restricts REPLACE to operations that maintain the same column mapping mode. In the future, we will loosen this restriction but for now this lessens the scope of this PR.
How was this patch tested?
Adds unit tests.