Skip to content
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

Add truncate history support for DROP FEATURE command #2045

Closed
wants to merge 1 commit into from

Conversation

andreaschat-db
Copy link
Contributor

Which Delta project/connector is this regarding?

  • Spark
  • Standalone
  • Flink
  • Kernel
  • Other (fill in here)

Description

The DROP FEATURE command allows to drop table features from Delta Tables. Dropping a reader+writer feature is performed in two steps:

  1. We clean all traces of the feature in the latest version and inform the user they need to wait until the retention period is over.
  2. After the retention period is over, the user executes the command again and the protocol is downgraded.

This PR adds the TRUNCATE HISTORY option in DROP FEATURE command. The new option is automatically sets the history retention period to minimum and cleans up metadata. This operation occurs at the second time the user invokes the operation.

How was this patch tested?

Added tests in DeltaProtocolVersionSuite and DeltaErrorsSuite.

Does this PR introduce any user-facing changes?

Introduces the TRUNCATE HISTORY option in ALTER TABLE ... DROP FEATURE command. This can be used as follows:

ALTER TABLE table_name DROP FEATURE feature_name [TRUNCATE HISTORY]

The new option allows to truncate history older than the minimum retention period when dropping a reader+writer feature.

@andreaschat-db andreaschat-db changed the title Add Truncate History support in table feature removal. [Issue-2008] Add Truncate History support in table feature removal. Sep 12, 2023
@andreaschat-db andreaschat-db changed the title [Issue-2008] Add Truncate History support in table feature removal. [ISSUE-2008] Add Truncate History support in table feature removal. Sep 12, 2023
@andreaschat-db andreaschat-db changed the title [ISSUE-2008] Add Truncate History support in table feature removal. Add Truncate History support in table feature removal. Sep 12, 2023
@andreaschat-db andreaschat-db changed the title Add Truncate History support in table feature removal. Add truncate history support for DROP FEATURE command Sep 12, 2023
Copy link
Collaborator

@vkorukanti vkorukanti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm.

  1. Make sure to add documentation for this feature as this is a user-facing command
  2. Are there Scala/Python APIs for the drop table feature?

@@ -2462,18 +2519,25 @@ trait DeltaProtocolVersionSuiteBase extends QueryTest
}

// If the property is re-disabled we pick up the issue during the history check.
val errorClass = if (reDisable) {
"DELTA_FEATURE_DROP_HISTORICAL_VERSIONS_EXIST"
if (reDisable) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: seems like duplicated code, Can we revert to the earlier method?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am planning to follow up with refactor PR of drop feature tests. It should cover this issue as well.

@andreaschat-db
Copy link
Contributor Author

lgtm.

  1. Make sure to add documentation for this feature as this is a user-facing command

Sure!

  1. Are there Scala/Python APIs for the drop table feature?

Technically, you could use the scala API but I do not see documentation for other Alter Table commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants