Downgrade to the minimum supported protocol when a table is using only legacy features #2750
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
When CDF is enabled on a table using
Protocol(3, 7)
without any other features,DROP FEATURE
cannot downgrade the table protocol version toProtocol(1, 4)
.Protocol(1, 4).implicitlySupportedFeatures
always return a long listSet(org.apache.spark.sql.delta.ChangeDataFeedTableFeature$@5d56d7c5, org.apache.spark.sql.delta.CheckConstraintsTableFeature$@a7c32f7, org.apache.spark.sql.delta.InvariantsTableFeature$@10898af, org.apache.spark.sql.delta.AppendOnlyTableFeature$@760cb590, org.apache.spark.sql.delta.GeneratedColumnsTableFeature$@6a08f493)
butProtocol(3,7,None,[changeDataFeed]).implicitlySupportedFeatures
returns an empty set. The code requiresnewProtocol.implicitlySupportedFeatures
must be the same asoldProtocol.implicitlySupportedFeatures
. This check prevents downgrading toProtocol(1, 4)
.This PR changes the check to:
newProtocol.implicitlySupportedFeatures
must be the superset ofoldProtocol.implicitlySupportedFeatures
. This will allow DROP FEATURE to downgrade the protocol further.How was this patch tested?
The new unit test.
Does this PR introduce any user-facing changes?
Yep.
DROP FEATURE
can downgrade the protocol further to the right minimum required protocol of CDF or other legacy features.