Skip to content

Commit 59795fa

Browse files
committed
Remove the check that disables writes to Delta tables with deletion vectors
Given that now we have support for writing into DV tables and table utility operations as as part of the delta-io#1485 and delta-io#1591, we should remove the check. Closes delta-io#1736
1 parent d587e4c commit 59795fa

File tree

7 files changed

+2
-246
lines changed

7 files changed

+2
-246
lines changed

core/src/main/scala/org/apache/spark/sql/delta/OptimisticTransaction.scala

-2
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ class OptimisticTransaction
139139
(implicit override val clock: Clock)
140140
extends OptimisticTransactionImpl
141141
with DeltaLogging {
142-
DeletionVectorUtils.assertDeletionVectorsNotReadable(spark, snapshot.metadata, snapshot.protocol)
143142

144143
/** Creates a new OptimisticTransaction.
145144
*
@@ -563,7 +562,6 @@ trait OptimisticTransactionImpl extends TransactionalWrite
563562
newMetadataTmp = RowId.verifyAndUpdateMetadata(
564563
spark, protocol, snapshot.metadata, newMetadataTmp, isCreatingNewTable)
565564

566-
DeletionVectorUtils.assertDeletionVectorsNotEnabled(spark, newMetadataTmp, protocol)
567565
assertMetadata(newMetadataTmp)
568566
logInfo(s"Updated metadata from ${newMetadata.getOrElse("-")} to $newMetadataTmp")
569567
newMetadata = Some(newMetadataTmp)

core/src/main/scala/org/apache/spark/sql/delta/commands/DeleteCommand.scala

+2-5
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import org.apache.spark.sql.delta.commands.DeleteCommand.{rewritingFilesMsg, FIN
2222
import org.apache.spark.sql.delta.commands.MergeIntoCommand.totalBytesAndDistinctPartitionValues
2323
import org.apache.spark.sql.delta.files.TahoeBatchFileIndex
2424
import org.apache.spark.sql.delta.sources.DeltaSQLConf
25-
import org.apache.spark.sql.delta.util.Utils
2625
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
2726

2827
import org.apache.spark.SparkContext
@@ -440,10 +439,8 @@ case class DeleteCommand(
440439

441440
def shouldWritePersistentDeletionVectors(
442441
spark: SparkSession, txn: OptimisticTransaction): Boolean = {
443-
// DELETE with DVs only enabled for tests.
444-
Utils.isTesting &&
445-
spark.conf.get(DeltaSQLConf.DELETE_USE_PERSISTENT_DELETION_VECTORS) &&
446-
DeletionVectorUtils.deletionVectorsWritable(txn.snapshot)
442+
spark.conf.get(DeltaSQLConf.DELETE_USE_PERSISTENT_DELETION_VECTORS) &&
443+
DeletionVectorUtils.deletionVectorsWritable(txn.snapshot)
447444
}
448445
}
449446

core/src/main/scala/org/apache/spark/sql/delta/commands/DeletionVectorUtils.scala

-37
Original file line numberDiff line numberDiff line change
@@ -85,43 +85,6 @@ trait DeletionVectorUtils {
8585
protocol.isFeatureSupported(DeletionVectorsTableFeature) &&
8686
metadata.format.provider == "parquet" // DVs are only supported on parquet tables.
8787
}
88-
89-
/**
90-
* Utility method that checks the table has no Deletion Vectors enabled. Deletion vectors
91-
* are supported in read-only mode for now. Any updates to tables with deletion vectors
92-
* feature are disabled until we add support.
93-
*/
94-
def assertDeletionVectorsNotReadable(
95-
spark: SparkSession, metadata: Metadata, protocol: Protocol): Unit = {
96-
val disable =
97-
Utils.isTesting && // We are in testing and enabled blocking updates on DV tables
98-
spark.conf.get(DeltaSQLConf.DELTA_ENABLE_BLOCKING_UPDATES_ON_DV_TABLES)
99-
if (!disable && deletionVectorsReadable(protocol, metadata)) {
100-
throw new UnsupportedOperationException(
101-
"Updates to tables with Deletion Vectors feature enabled are not supported in " +
102-
"this version of Delta Lake.")
103-
}
104-
}
105-
106-
/**
107-
* Utility method that checks the table metadata has no deletion vectors enabled. Deletion vectors
108-
* are supported in read-only mode for now. Any updates to metadata to enable deletion vectors are
109-
* blocked until we add support.
110-
*/
111-
def assertDeletionVectorsNotEnabled(
112-
spark: SparkSession, metadata: Metadata, protocol: Protocol): Unit = {
113-
val disable =
114-
Utils.isTesting && // We are in testing and enabled blocking updates on DV tables
115-
spark.conf.get(DeltaSQLConf.DELTA_ENABLE_BLOCKING_UPDATES_ON_DV_TABLES)
116-
if (!disable &&
117-
(protocol.isFeatureSupported(DeletionVectorsTableFeature) ||
118-
DeltaConfigs.ENABLE_DELETION_VECTORS_CREATION.fromMetaData(metadata)
119-
)
120-
) {
121-
throw new UnsupportedOperationException(
122-
"Enabling Deletion Vectors on the table is not supported in this version of Delta Lake.")
123-
}
124-
}
12588
}
12689

12790
// To access utilities from places where mixing in a trait is inconvenient.

core/src/main/scala/org/apache/spark/sql/delta/commands/VacuumCommand.scala

-3
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,6 @@ object VacuumCommand extends VacuumCommandImpl with Serializable {
114114
require(snapshot.version >= 0, "No state defined for this table. Is this really " +
115115
"a Delta table? Refusing to garbage collect.")
116116

117-
DeletionVectorUtils.assertDeletionVectorsNotReadable(
118-
spark, snapshot.metadata, snapshot.protocol)
119-
120117
val snapshotTombstoneRetentionMillis = DeltaLog.tombstoneRetentionMillis(snapshot.metadata)
121118
val retentionMillis = retentionHours.map(h => TimeUnit.HOURS.toMillis(math.round(h)))
122119
checkRetentionPeriodSafety(spark, retentionMillis, snapshotTombstoneRetentionMillis)

core/src/main/scala/org/apache/spark/sql/delta/sources/DeltaSQLConf.scala

-9
Original file line numberDiff line numberDiff line change
@@ -1157,15 +1157,6 @@ trait DeltaSQLConfBase {
11571157
.booleanConf
11581158
.createWithDefault(true)
11591159

1160-
val DELTA_ENABLE_BLOCKING_UPDATES_ON_DV_TABLES =
1161-
buildConf("deletionVectors.updates.blocking.enabled")
1162-
.internal()
1163-
.doc(
1164-
"""Enable blocking updates on tables with Deletion Vectors
1165-
|Only change this for testing!""".stripMargin)
1166-
.booleanConf
1167-
.createWithDefault(true)
1168-
11691160
val DELTA_DUPLICATE_ACTION_CHECK_ENABLED =
11701161
buildConf("duplicateActionCheck.enabled")
11711162
.internal()

core/src/test/resources/delta/table-with-dv-feature-enabled/_delta_log/00000000000000000000.json

-4
This file was deleted.

core/src/test/scala/org/apache/spark/sql/delta/deletionvectors/DisableUpdatesToDvEnabledTablesSuite.scala

-186
This file was deleted.

0 commit comments

Comments
 (0)