Skip to content

Commit

Permalink
Fixed DV DELETE on column mapping enabled tables
Browse files Browse the repository at this point in the history
Resolves #1886

Added ROW_INDEX_COLUMN_NAME in DELTA_INTERNAL_COLUMNS set so Delta consider it as internal field

Added test in `DeletionVectorsSuite.scala`

Closes #1891

GitOrigin-RevId: 5e881a392634d1636ac1864e08c4d92ff1cfeb26
  • Loading branch information
sherlockbeard authored and allisonport-db committed Jul 20, 2023
1 parent 355804c commit e41db5c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ trait DeltaColumnMappingBase extends DeltaLogging {
(CDCReader.CDC_COLUMNS_IN_DATA ++ Seq(
CDCReader.CDC_COMMIT_VERSION,
CDCReader.CDC_COMMIT_TIMESTAMP,
DeltaParquetFileFormat.IS_ROW_DELETED_COLUMN_NAME)
DeltaParquetFileFormat.IS_ROW_DELETED_COLUMN_NAME,
DeltaParquetFileFormat.ROW_INDEX_COLUMN_NAME)
).map(_.toLowerCase(Locale.ROOT)).toSet

val supportedModes: Set[DeltaColumnMappingMode] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,23 @@ class DeletionVectorsSuite extends QueryTest
}
}

Seq("name", "id").foreach(mode =>
test(s"DELETE with DVs with column mapping mode=$mode") {
withTempDir { dirName =>
val path = dirName.getAbsolutePath
val data = (0 until 50).map(x => (x % 10, x, s"foo${x % 5}"))
spark.conf.set("spark.databricks.delta.properties.defaults.columnMapping.mode", mode)
data.toDF("part", "col1", "col2").write.format("delta").partitionBy(
"part").save(path)
val tableLog = DeltaLog.forTable(spark, path)
enableDeletionVectorsInTable(tableLog, true)
spark.sql(s"DELETE FROM delta.`$path` WHERE col1 = 2")
checkAnswer(spark.sql(s"select * from delta.`$path` WHERE col1 = 2"), Seq())
verifyDVsExist(tableLog, 1)
}
}
)

test("DELETE with DVs - existing table already has DVs") {
withSQLConf(DeltaSQLConf.DELETE_USE_PERSISTENT_DELETION_VECTORS.key -> "true") {
withTempDir { tempDir =>
Expand Down

0 comments on commit e41db5c

Please # to comment.