diff --git a/plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/transactionlog/DeltaLakeSchemaSupport.java b/plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/transactionlog/DeltaLakeSchemaSupport.java index 5cbf3925ff0d7..46055aec1e143 100644 --- a/plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/transactionlog/DeltaLakeSchemaSupport.java +++ b/plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/transactionlog/DeltaLakeSchemaSupport.java @@ -119,6 +119,7 @@ private DeltaLakeSchemaSupport() {} .add(CHANGE_DATA_FEED_FEATURE_NAME) .add(COLUMN_MAPPING_FEATURE_NAME) .add(TIMESTAMP_NTZ_FEATURE_NAME) + .add(DELETION_VECTORS_FEATURE_NAME) .build(); public enum ColumnMappingMode diff --git a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeBasic.java b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeBasic.java index 7bdd52f5ecdaf..b301ceeae356c 100644 --- a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeBasic.java +++ b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeBasic.java @@ -96,7 +96,6 @@ public class TestDeltaLakeBasic private static final List OTHER_TABLES = ImmutableList.of( new ResourceTable("stats_with_minmax_nulls", "deltalake/stats_with_minmax_nulls"), new ResourceTable("no_column_stats", "databricks73/no_column_stats"), - new ResourceTable("deletion_vectors", "databricks122/deletion_vectors"), new ResourceTable("timestamp_ntz", "databricks131/timestamp_ntz"), new ResourceTable("timestamp_ntz_partition", "databricks131/timestamp_ntz_partition")); @@ -936,8 +935,30 @@ public void testIdentityColumns() */ @Test public void testDeletionVectors() + throws Exception { - assertQuery("SELECT * FROM deletion_vectors", "VALUES (1, 11)"); + String tableName = "deletion_vectors" + randomNameSuffix(); + + Path tableLocation = Files.createTempFile(tableName, null); + copyDirectoryContents(new File(Resources.getResource("databricks122/deletion_vectors").toURI()).toPath(), tableLocation); + assertUpdate("CALL system.register_table('%s', '%s', '%s')".formatted(getSession().getSchema().orElseThrow(), tableName, tableLocation.toUri())); + + assertQuery("SELECT * FROM " + tableName, "VALUES (1, 11)"); + + assertUpdate("INSERT INTO " + tableName + " VALUES (3, 31), (3, 32)", 2); + assertQuery("SELECT * FROM " + tableName, "VALUES (1, 11), (3, 31), (3, 32)"); + + assertUpdate("DELETE FROM " + tableName + " WHERE a = 3 AND b = 31", 1); + assertQuery("SELECT * FROM " + tableName, "VALUES (1, 11), (3, 32)"); + + assertUpdate("UPDATE " + tableName + " SET a = -3 WHERE b = 32", 1); + assertQuery("SELECT * FROM " + tableName, "VALUES (1, 11), (-3, 32)"); + + assertUpdate("MERGE INTO " + tableName + " t USING " + tableName + " s " + + "ON (t.a = s.a) WHEN MATCHED THEN UPDATE SET b = -1", 2); + assertQuery("SELECT * FROM " + tableName, "VALUES (1, -1), (-3, -1)"); + + assertUpdate("DROP TABLE " + tableName); } @Test diff --git a/testing/trino-product-tests/src/main/java/io/trino/tests/product/deltalake/TestDeltaLakeDeleteCompatibility.java b/testing/trino-product-tests/src/main/java/io/trino/tests/product/deltalake/TestDeltaLakeDeleteCompatibility.java index 58fd4170cf7c9..ec8ce1ab3695a 100644 --- a/testing/trino-product-tests/src/main/java/io/trino/tests/product/deltalake/TestDeltaLakeDeleteCompatibility.java +++ b/testing/trino-product-tests/src/main/java/io/trino/tests/product/deltalake/TestDeltaLakeDeleteCompatibility.java @@ -261,15 +261,16 @@ public void testDeletionVectors(String mode) .contains(row("a", "integer", "", ""), row("b", "integer", "", "")); // TODO https://github.com/trinodb/trino/issues/17063 Use Delta Deletion Vectors for row-level deletes - assertQueryFailure(() -> onTrino().executeQuery("INSERT INTO delta.default." + tableName + " VALUES (3, 33)")) - .hasMessageContaining("Unsupported writer features: [deletionVectors]"); - assertQueryFailure(() -> onTrino().executeQuery("DELETE FROM delta.default." + tableName)) - .hasMessageContaining("Unsupported writer features: [deletionVectors]"); - assertQueryFailure(() -> onTrino().executeQuery("UPDATE delta.default." + tableName + " SET a = 3")) - .hasMessageContaining("Unsupported writer features: [deletionVectors]"); - assertQueryFailure(() -> onTrino().executeQuery("MERGE INTO delta.default." + tableName + " t USING delta.default." + tableName + " s " + - "ON (t.a = s.a) WHEN MATCHED THEN UPDATE SET b = -1")) - .hasMessageContaining("Unsupported writer features: [deletionVectors]"); + onTrino().executeQuery("INSERT INTO delta.default." + tableName + " VALUES (3, 33)"); + onTrino().executeQuery("DELETE FROM delta.default." + tableName + " WHERE a = 1"); + onTrino().executeQuery("UPDATE delta.default." + tableName + " SET a = 30 WHERE b = 33"); + onTrino().executeQuery("MERGE INTO delta.default." + tableName + " t USING delta.default." + tableName + " s " + + "ON (t.a = s.a) WHEN MATCHED THEN UPDATE SET b = -1"); + + assertThat(onDelta().executeQuery("SELECT * FROM default." + tableName)) + .containsOnly(row(2, -1), row(30, -1)); + assertThat(onTrino().executeQuery("SELECT * FROM delta.default." + tableName)) + .containsOnly(row(2, -1), row(30, -1)); } finally { dropDeltaTableWithRetry("default." + tableName); diff --git a/testing/trino-product-tests/src/main/java/io/trino/tests/product/deltalake/TestDeltaLakeWriteDatabricksCompatibility.java b/testing/trino-product-tests/src/main/java/io/trino/tests/product/deltalake/TestDeltaLakeWriteDatabricksCompatibility.java index cb35a28dfa0bc..2fface7eb80f7 100644 --- a/testing/trino-product-tests/src/main/java/io/trino/tests/product/deltalake/TestDeltaLakeWriteDatabricksCompatibility.java +++ b/testing/trino-product-tests/src/main/java/io/trino/tests/product/deltalake/TestDeltaLakeWriteDatabricksCompatibility.java @@ -421,10 +421,10 @@ public void testVacuumUnsupportedWriterFeature() "(a INT)" + "USING DELTA " + "LOCATION '" + ("s3://" + bucketName + "/" + directoryName) + "'" + - "TBLPROPERTIES ('delta.enableDeletionVectors' = true)"); + "TBLPROPERTIES ('delta.enableRowTracking' = true)"); try { assertThatThrownBy(() -> onTrino().executeQuery("CALL delta.system.vacuum('default', '" + tableName + "', '7d')")) - .hasMessageContaining("Cannot execute vacuum procedure with [deletionVectors] writer features"); + .hasMessageContaining("Cannot execute vacuum procedure with [rowTracking] writer features"); } finally { dropDeltaTableWithRetry("default." + tableName);