diff --git a/fe/fe-common/src/main/java/org/apache/doris/common/Config.java b/fe/fe-common/src/main/java/org/apache/doris/common/Config.java index 57b6cf0e2eb1f7..9c299576537b7f 100644 --- a/fe/fe-common/src/main/java/org/apache/doris/common/Config.java +++ b/fe/fe-common/src/main/java/org/apache/doris/common/Config.java @@ -2395,6 +2395,15 @@ public class Config extends ConfigBase { @ConfField public static boolean ignore_bdbje_log_checksum_read = false; + @ConfField(mutable = true, masterOnly = true, description = { + "是否在unique表mow上开启delete语句写delete predicate。若开启,会提升delete语句的性能," + + "但delete后进行部分列更新可能会出现部分数据错误的情况。若关闭,会降低delete语句的性能来保证正确性。", + "Enable the 'delete predicate' for DELETE statements. If enabled, it will enhance the performance of " + + "DELETE statements, but partial column updates after a DELETE may result in erroneous data. " + + "If disabled, it will reduce the performance of DELETE statements to ensure accuracy." + }) + public static boolean enable_mow_light_delete = false; + @ConfField(description = { "是否开启 Proxy Protocol 支持", "Whether to enable proxy protocol" diff --git a/fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java b/fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java index 36f82f524a196e..a40f0891b0bf04 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java +++ b/fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java @@ -513,6 +513,7 @@ public void processAlterTable(AlterTableStmt stmt) throws UserException { // currently, only in memory and storage policy property could reach here Preconditions.checkState(properties.containsKey(PropertyAnalyzer.PROPERTIES_INMEMORY) || properties.containsKey(PropertyAnalyzer.PROPERTIES_STORAGE_POLICY) + || properties.containsKey(PropertyAnalyzer.PROPERTIES_ENABLE_MOW_LIGHT_DELETE) || properties.containsKey(PropertyAnalyzer.PROPERTIES_IS_BEING_SYNCED) || properties.containsKey(PropertyAnalyzer.PROPERTIES_COMPACTION_POLICY) || properties.containsKey(PropertyAnalyzer.PROPERTIES_TIME_SERIES_COMPACTION_GOAL_SIZE_MBYTES) diff --git a/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java b/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java index 198aaf7410009f..9bf414ed6c93f3 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java +++ b/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java @@ -2215,6 +2215,7 @@ public void updateTableProperties(Database db, String tableName, Map propertie throw new AnalysisException(PropertyAnalyzer.ENABLE_UNIQUE_KEY_MERGE_ON_WRITE + " must be `true` or `false`"); } + public static boolean analyzeEnableDeleteOnDeletePredicate(Map properties) + throws AnalysisException { + if (properties == null || properties.isEmpty()) { + return false; + } + String value = properties.get(PropertyAnalyzer.PROPERTIES_ENABLE_MOW_LIGHT_DELETE); + if (value == null) { + return false; + } + properties.remove(PropertyAnalyzer.PROPERTIES_ENABLE_MOW_LIGHT_DELETE); + if (value.equals("true")) { + return true; + } else if (value.equals("false")) { + return false; + } + throw new AnalysisException( + PropertyAnalyzer.PROPERTIES_ENABLE_MOW_LIGHT_DELETE + " must be `true` or `false`"); + } + /** * Check the type property of the catalog props. */ diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java index cfe94a1dded9ab..285d60d331656b 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java +++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java @@ -2203,6 +2203,18 @@ private boolean createOlapTable(Database db, CreateTableStmt stmt) throws UserEx } olapTable.setEnableUniqueKeyMergeOnWrite(enableUniqueKeyMergeOnWrite); + boolean enableDeleteOnDeletePredicate = false; + try { + enableDeleteOnDeletePredicate = PropertyAnalyzer.analyzeEnableDeleteOnDeletePredicate(properties); + } catch (AnalysisException e) { + throw new DdlException(e.getMessage()); + } + if (enableDeleteOnDeletePredicate && !enableUniqueKeyMergeOnWrite) { + throw new DdlException(PropertyAnalyzer.PROPERTIES_ENABLE_MOW_LIGHT_DELETE + + " property is only supported for unique merge-on-write table"); + } + olapTable.setEnableMowLightDelete(enableDeleteOnDeletePredicate); + boolean enableSingleReplicaCompaction = false; try { enableSingleReplicaCompaction = PropertyAnalyzer.analyzeEnableSingleReplicaCompaction(properties); diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/DeleteCommand.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/DeleteCommand.java index 880747cdc5577e..b356a6db5d8aad 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/DeleteCommand.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/DeleteCommand.java @@ -21,10 +21,10 @@ import org.apache.doris.catalog.KeysType; import org.apache.doris.catalog.OlapTable; import org.apache.doris.catalog.TableIf; +import org.apache.doris.nereids.analyzer.UnboundAlias; import org.apache.doris.nereids.analyzer.UnboundOlapTableSink; import org.apache.doris.nereids.analyzer.UnboundSlot; import org.apache.doris.nereids.exceptions.AnalysisException; -import org.apache.doris.nereids.trees.expressions.Alias; import org.apache.doris.nereids.trees.expressions.NamedExpression; import org.apache.doris.nereids.trees.expressions.literal.TinyIntLiteral; import org.apache.doris.nereids.trees.plans.Explainable; @@ -98,15 +98,16 @@ public LogicalPlan completeQueryPlan(ConnectContext ctx, LogicalPlan logicalQuer String tableName = tableAlias != null ? tableAlias : targetTable.getName(); for (Column column : targetTable.getFullSchema()) { if (column.getName().equalsIgnoreCase(Column.DELETE_SIGN)) { - selectLists.add(new Alias(new TinyIntLiteral(((byte) 1)), Column.DELETE_SIGN)); - } else if (column.getName().equalsIgnoreCase(Column.SEQUENCE_COL)) { + selectLists.add(new UnboundAlias(new TinyIntLiteral(((byte) 1)), Column.DELETE_SIGN)); + } else if (column.getName().equalsIgnoreCase(Column.SEQUENCE_COL) + && targetTable.getSequenceMapCol() != null) { selectLists.add(new UnboundSlot(tableName, targetTable.getSequenceMapCol())); } else if (column.isKey()) { selectLists.add(new UnboundSlot(tableName, column.getName())); } else if (!isMow && (!column.isVisible() || (!column.isAllowNull() && !column.hasDefaultValue()))) { selectLists.add(new UnboundSlot(tableName, column.getName())); } else { - continue; + selectLists.add(new UnboundSlot(tableName, column.getName())); } cols.add(column.getName()); } diff --git a/fe/fe-core/src/test/java/org/apache/doris/analysis/CreateTableAsSelectStmtTest.java b/fe/fe-core/src/test/java/org/apache/doris/analysis/CreateTableAsSelectStmtTest.java index fa3a029c43bfc9..7ce0fdd64f3be1 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/analysis/CreateTableAsSelectStmtTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/analysis/CreateTableAsSelectStmtTest.java @@ -96,7 +96,8 @@ public void testDecimal() throws Exception { + "\"storage_format\" = \"V2\",\n" + "\"light_schema_change\" = \"true\",\n" + "\"disable_auto_compaction\" = \"false\",\n" - + "\"enable_single_replica_compaction\" = \"false\"\n" + + "\"enable_single_replica_compaction\" = \"false\",\n" + + "\"enable_mow_light_delete\" = \"false\"\n" + ");", showCreateTableByName("select_decimal_table").getResultRows().get(0).get(1)); String selectFromDecimal1 = @@ -117,7 +118,8 @@ public void testDecimal() throws Exception { + "\"storage_format\" = \"V2\",\n" + "\"light_schema_change\" = \"true\",\n" + "\"disable_auto_compaction\" = \"false\",\n" - + "\"enable_single_replica_compaction\" = \"false\"\n" + + "\"enable_single_replica_compaction\" = \"false\",\n" + + "\"enable_mow_light_delete\" = \"false\"\n" + ");", showCreateTableByName("select_decimal_table_1").getResultRows().get(0).get(1)); } else { @@ -134,7 +136,8 @@ public void testDecimal() throws Exception { + "\"storage_format\" = \"V2\",\n" + "\"light_schema_change\" = \"true\",\n" + "\"disable_auto_compaction\" = \"false\",\n" - + "\"enable_single_replica_compaction\" = \"false\"\n" + + "\"enable_single_replica_compaction\" = \"false\",\n" + + "\"enable_mow_light_delete\" = \"false\"\n" + ");", showCreateTableByName("select_decimal_table_1").getResultRows().get(0).get(1)); } @@ -169,7 +172,8 @@ public void testVarchar() throws Exception { + "\"storage_format\" = \"V2\",\n" + "\"light_schema_change\" = \"true\",\n" + "\"disable_auto_compaction\" = \"false\",\n" - + "\"enable_single_replica_compaction\" = \"false\"\n" + + "\"enable_single_replica_compaction\" = \"false\",\n" + + "\"enable_mow_light_delete\" = \"false\"\n" + ");", showResultSet.getResultRows().get(0).get(1)); } @@ -193,7 +197,8 @@ public void testFunction() throws Exception { + "\"storage_format\" = \"V2\",\n" + "\"light_schema_change\" = \"true\",\n" + "\"disable_auto_compaction\" = \"false\",\n" - + "\"enable_single_replica_compaction\" = \"false\"\n" + + "\"enable_single_replica_compaction\" = \"false\",\n" + + "\"enable_mow_light_delete\" = \"false\"\n" + ");", showResultSet1.getResultRows().get(0).get(1)); @@ -219,7 +224,8 @@ public void testFunction() throws Exception { + "\"storage_format\" = \"V2\",\n" + "\"light_schema_change\" = \"true\",\n" + "\"disable_auto_compaction\" = \"false\",\n" - + "\"enable_single_replica_compaction\" = \"false\"\n" + + "\"enable_single_replica_compaction\" = \"false\",\n" + + "\"enable_mow_light_delete\" = \"false\"\n" + ");", showResultSet2.getResultRows().get(0).get(1)); } @@ -242,7 +248,8 @@ public void testAlias() throws Exception { + "\"storage_format\" = \"V2\",\n" + "\"light_schema_change\" = \"true\",\n" + "\"disable_auto_compaction\" = \"false\",\n" - + "\"enable_single_replica_compaction\" = \"false\"\n" + + "\"enable_single_replica_compaction\" = \"false\",\n" + + "\"enable_mow_light_delete\" = \"false\"\n" + ");", showResultSet1.getResultRows().get(0).get(1)); String selectAlias2 = "create table `test`.`select_alias_2` PROPERTIES(\"replication_num\" = \"1\") " + "as select userId as alias_name, username from `test`.`varchar_table`"; @@ -261,7 +268,8 @@ public void testAlias() throws Exception { + "\"storage_format\" = \"V2\",\n" + "\"light_schema_change\" = \"true\",\n" + "\"disable_auto_compaction\" = \"false\",\n" - + "\"enable_single_replica_compaction\" = \"false\"\n" + + "\"enable_single_replica_compaction\" = \"false\",\n" + + "\"enable_mow_light_delete\" = \"false\"\n" + ");", showResultSet2.getResultRows().get(0).get(1)); } @@ -287,7 +295,8 @@ public void testJoin() throws Exception { + "\"storage_format\" = \"V2\",\n" + "\"light_schema_change\" = \"true\",\n" + "\"disable_auto_compaction\" = \"false\",\n" - + "\"enable_single_replica_compaction\" = \"false\"\n" + + "\"enable_single_replica_compaction\" = \"false\",\n" + + "\"enable_mow_light_delete\" = \"false\"\n" + ");", showResultSet.getResultRows().get(0).get(1)); String selectFromJoin1 = "create table `test`.`select_join1` PROPERTIES(\"replication_num\" = \"1\") " @@ -310,7 +319,8 @@ public void testJoin() throws Exception { + "\"storage_format\" = \"V2\",\n" + "\"light_schema_change\" = \"true\",\n" + "\"disable_auto_compaction\" = \"false\",\n" - + "\"enable_single_replica_compaction\" = \"false\"\n" + + "\"enable_single_replica_compaction\" = \"false\",\n" + + "\"enable_mow_light_delete\" = \"false\"\n" + ");", showResultSet1.getResultRows().get(0).get(1)); } @@ -337,7 +347,8 @@ public void testName() throws Exception { + "\"storage_format\" = \"V2\",\n" + "\"light_schema_change\" = \"true\",\n" + "\"disable_auto_compaction\" = \"false\",\n" - + "\"enable_single_replica_compaction\" = \"false\"\n" + + "\"enable_single_replica_compaction\" = \"false\",\n" + + "\"enable_mow_light_delete\" = \"false\"\n" + ");", showResultSet.getResultRows().get(0).get(1)); } @@ -361,7 +372,8 @@ public void testUnion() throws Exception { + "\"storage_format\" = \"V2\",\n" + "\"light_schema_change\" = \"true\",\n" + "\"disable_auto_compaction\" = \"false\",\n" - + "\"enable_single_replica_compaction\" = \"false\"\n" + + "\"enable_single_replica_compaction\" = \"false\",\n" + + "\"enable_mow_light_delete\" = \"false\"\n" + ");", showResultSet.getResultRows().get(0).get(1)); } @@ -384,7 +396,8 @@ public void testCte() throws Exception { + "\"storage_format\" = \"V2\",\n" + "\"light_schema_change\" = \"true\",\n" + "\"disable_auto_compaction\" = \"false\",\n" - + "\"enable_single_replica_compaction\" = \"false\"\n" + + "\"enable_single_replica_compaction\" = \"false\",\n" + + "\"enable_mow_light_delete\" = \"false\"\n" + ");", showResultSet.getResultRows().get(0).get(1)); String selectFromCteAndUnion = "create table `test`.`select_cte_union` PROPERTIES(\"replication_num\" = \"1\")" @@ -403,7 +416,8 @@ public void testCte() throws Exception { + "\"storage_format\" = \"V2\",\n" + "\"light_schema_change\" = \"true\",\n" + "\"disable_auto_compaction\" = \"false\",\n" - + "\"enable_single_replica_compaction\" = \"false\"\n" + + "\"enable_single_replica_compaction\" = \"false\",\n" + + "\"enable_mow_light_delete\" = \"false\"\n" + ");", showResultSet1.getResultRows().get(0).get(1)); } @@ -429,7 +443,8 @@ public void testPartition() throws Exception { + "\"storage_format\" = \"V2\",\n" + "\"light_schema_change\" = \"true\",\n" + "\"disable_auto_compaction\" = \"false\",\n" - + "\"enable_single_replica_compaction\" = \"false\"\n" + + "\"enable_single_replica_compaction\" = \"false\",\n" + + "\"enable_mow_light_delete\" = \"false\"\n" + ");", showResultSet.getResultRows().get(0).get(1)); } @@ -454,7 +469,8 @@ public void testDefaultTimestamp() throws Exception { + "\"storage_format\" = \"V2\",\n" + "\"light_schema_change\" = \"true\",\n" + "\"disable_auto_compaction\" = \"false\",\n" - + "\"enable_single_replica_compaction\" = \"false\"\n" + + "\"enable_single_replica_compaction\" = \"false\",\n" + + "\"enable_mow_light_delete\" = \"false\"\n" + ");", showResultSet.getResultRows().get(0).get(1)); } @@ -478,7 +494,8 @@ public void testAggValue() throws Exception { + "\"storage_format\" = \"V2\",\n" + "\"light_schema_change\" = \"true\",\n" + "\"disable_auto_compaction\" = \"false\",\n" - + "\"enable_single_replica_compaction\" = \"false\"\n" + + "\"enable_single_replica_compaction\" = \"false\",\n" + + "\"enable_mow_light_delete\" = \"false\"\n" + ");", showResultSet.getResultRows().get(0).get(1)); } @@ -503,7 +520,8 @@ public void testUseKeyType() throws Exception { + "\"storage_format\" = \"V2\",\n" + "\"light_schema_change\" = \"true\",\n" + "\"disable_auto_compaction\" = \"false\",\n" - + "\"enable_single_replica_compaction\" = \"false\"\n" + + "\"enable_single_replica_compaction\" = \"false\",\n" + + "\"enable_mow_light_delete\" = \"false\"\n" + ");", showResultSet.getResultRows().get(0).get(1)); } @@ -552,7 +570,8 @@ public void testQuerySchema() throws Exception { + "\"storage_format\" = \"V2\",\n" + "\"light_schema_change\" = \"true\",\n" + "\"disable_auto_compaction\" = \"false\",\n" - + "\"enable_single_replica_compaction\" = \"false\"\n" + + "\"enable_single_replica_compaction\" = \"false\",\n" + + "\"enable_mow_light_delete\" = \"false\"\n" + ");", createTableStmts.get(0)); } else { @@ -569,7 +588,8 @@ public void testQuerySchema() throws Exception { + "\"storage_format\" = \"V2\",\n" + "\"light_schema_change\" = \"true\",\n" + "\"disable_auto_compaction\" = \"false\",\n" - + "\"enable_single_replica_compaction\" = \"false\"\n" + + "\"enable_single_replica_compaction\" = \"false\",\n" + + "\"enable_mow_light_delete\" = \"false\"\n" + ");", createTableStmts.get(0)); } @@ -600,7 +620,8 @@ public void testVarcharLength() throws Exception { + "\"storage_format\" = \"V2\",\n" + "\"light_schema_change\" = \"true\",\n" + "\"disable_auto_compaction\" = \"false\",\n" - + "\"enable_single_replica_compaction\" = \"false\"\n" + + "\"enable_single_replica_compaction\" = \"false\",\n" + + "\"enable_mow_light_delete\" = \"false\"\n" + ");", showStr); } diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/DeleteCommandTest.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/DeleteCommandTest.java index 23a89ffe0415aa..cee3b0a4242966 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/DeleteCommandTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/DeleteCommandTest.java @@ -83,17 +83,15 @@ public void testFromClauseDelete() throws AnalysisException { logicalOlapTableSink( logicalProject( logicalJoin( - logicalProject( - logicalJoin( - logicalProject( - logicalFilter( - logicalOlapScan() - ) - ), - logicalProject( - logicalFilter( - logicalOlapScan() - ) + logicalJoin( + logicalProject( + logicalFilter( + logicalOlapScan() + ) + ), + logicalProject( + logicalFilter( + logicalOlapScan() ) ) ), diff --git a/regression-test/data/compaction/test_full_compaction.out b/regression-test/data/compaction/test_full_compaction.out index ead5be01b4e6b0..b25fdad93145cc 100644 --- a/regression-test/data/compaction/test_full_compaction.out +++ b/regression-test/data/compaction/test_full_compaction.out @@ -32,10 +32,12 @@ 2 2 2 20 2 200 +3 0 3 100 3 300 -- !select_final -- 1 100 2 200 +3 0 diff --git a/regression-test/data/compaction/test_full_compaction_by_table_id.out b/regression-test/data/compaction/test_full_compaction_by_table_id.out index ead5be01b4e6b0..b25fdad93145cc 100644 --- a/regression-test/data/compaction/test_full_compaction_by_table_id.out +++ b/regression-test/data/compaction/test_full_compaction_by_table_id.out @@ -32,10 +32,12 @@ 2 2 2 20 2 200 +3 0 3 100 3 300 -- !select_final -- 1 100 2 200 +3 0 diff --git a/regression-test/data/delete_p0/test_delete_on_value.out b/regression-test/data/delete_p0/test_delete_on_value.out index 2bc8846297d3dd..2b50d5bd9e1ba7 100644 --- a/regression-test/data/delete_p0/test_delete_on_value.out +++ b/regression-test/data/delete_p0/test_delete_on_value.out @@ -29,11 +29,6 @@ -- !sql -- 1 1 1 0 2 2 2 0 -3 3 3 0 -4 4 4 0 -5 5 5 0 -6 6 6 0 -7 7 7 0 8 8 8 0 9 9 9 0 @@ -55,12 +50,18 @@ -- !sql -- 1 1 1 0 2 2 2 0 +3 \N \N 1 3 3 3 0 +4 \N \N 1 4 4 4 0 4 4 4 0 +5 \N \N 1 +5 \N \N 1 5 5 5 0 5 5 5 0 +6 \N \N 1 6 6 6 0 +7 \N \N 1 7 7 7 0 8 8 8 0 9 9 9 0 @@ -77,6 +78,7 @@ -- !sql -- 1 1 5 0 3 5 1 1 10 0 2 10 +1 1 10 1 4 10 -- !sql -- 1 1 10 diff --git a/regression-test/data/index_p0/test_bitmap_index.out b/regression-test/data/index_p0/test_bitmap_index.out index 402c0c88493dab..95e9be7bb1dae1 100644 --- a/regression-test/data/index_p0/test_bitmap_index.out +++ b/regression-test/data/index_p0/test_bitmap_index.out @@ -102,9 +102,6 @@ usage_mode INT Yes false \N NONE -- !sql -- 2 --- !sql -- -2 - -- !sql -- 2023-08-25T10:00 123 2023-08-25T10:00 1 1 1 2023-08-25T11:00 123 2023-08-25T11:00 2 2 2 diff --git a/regression-test/data/nereids_p0/delete/delete_mow_partial_update.out b/regression-test/data/nereids_p0/delete/delete_mow_partial_update.out index 787f854bea29bc..b4237a038036db 100644 --- a/regression-test/data/nereids_p0/delete/delete_mow_partial_update.out +++ b/regression-test/data/nereids_p0/delete/delete_mow_partial_update.out @@ -15,12 +15,12 @@ 5 5 -- !sql -- -1 \N 1 1 1 0 -2 \N 1 +1 1 1 2 2 0 -3 \N 1 +2 2 1 3 3 0 +3 3 1 4 4 0 5 5 0 @@ -61,12 +61,12 @@ 5 5 -- !sql -- -1 \N 1 1 1 0 -2 \N 1 +1 1 1 2 2 0 -3 \N 1 +2 2 1 3 3 0 +3 3 1 4 4 0 5 5 0 diff --git a/regression-test/data/show_p0/test_show_create_table_and_views.out b/regression-test/data/show_p0/test_show_create_table_and_views.out index 804174d629ab68..d8b8047f78d3ea 100644 --- a/regression-test/data/show_p0/test_show_create_table_and_views.out +++ b/regression-test/data/show_p0/test_show_create_table_and_views.out @@ -1,6 +1,6 @@ -- This file is automatically generated. You should know what you did if you want to edit this -- !show -- -show_create_table_and_views_table CREATE TABLE `show_create_table_and_views_table` (\n `user_id` LARGEINT NOT NULL,\n `good_id` LARGEINT NOT NULL,\n `cost` BIGINT SUM NULL DEFAULT "0"\n) ENGINE=OLAP\nAGGREGATE KEY(`user_id`, `good_id`)\nPARTITION BY RANGE(`good_id`)\n(PARTITION p1 VALUES [("-170141183460469231731687303715884105728"), ("100")),\nPARTITION p2 VALUES [("100"), ("200")),\nPARTITION p3 VALUES [("200"), ("300")),\nPARTITION p4 VALUES [("300"), ("400")),\nPARTITION p5 VALUES [("400"), ("500")),\nPARTITION p6 VALUES [("500"), ("600")),\nPARTITION p7 VALUES [("600"), (MAXVALUE)))\nDISTRIBUTED BY HASH(`user_id`) BUCKETS 2\nPROPERTIES (\n"replication_allocation" = "tag.location.default: 1",\n"is_being_synced" = "false",\n"storage_medium" = "hdd",\n"storage_format" = "V2",\n"light_schema_change" = "true",\n"disable_auto_compaction" = "false",\n"binlog.enable" = "false",\n"binlog.ttl_seconds" = "86400",\n"binlog.max_bytes" = "9223372036854775807",\n"binlog.max_history_nums" = "9223372036854775807",\n"enable_single_replica_compaction" = "false"\n); +show_create_table_and_views_table CREATE TABLE `show_create_table_and_views_table` (\n `user_id` LARGEINT NOT NULL,\n `good_id` LARGEINT NOT NULL,\n `cost` BIGINT SUM NULL DEFAULT "0"\n) ENGINE=OLAP\nAGGREGATE KEY(`user_id`, `good_id`)\nPARTITION BY RANGE(`good_id`)\n(PARTITION p1 VALUES [("-170141183460469231731687303715884105728"), ("100")),\nPARTITION p2 VALUES [("100"), ("200")),\nPARTITION p3 VALUES [("200"), ("300")),\nPARTITION p4 VALUES [("300"), ("400")),\nPARTITION p5 VALUES [("400"), ("500")),\nPARTITION p6 VALUES [("500"), ("600")),\nPARTITION p7 VALUES [("600"), (MAXVALUE)))\nDISTRIBUTED BY HASH(`user_id`) BUCKETS 2\nPROPERTIES (\n"replication_allocation" = "tag.location.default: 1",\n"is_being_synced" = "false",\n"storage_medium" = "hdd",\n"storage_format" = "V2",\n"light_schema_change" = "true",\n"disable_auto_compaction" = "false",\n"binlog.enable" = "false",\n"binlog.ttl_seconds" = "86400",\n"binlog.max_bytes" = "9223372036854775807",\n"binlog.max_history_nums" = "9223372036854775807",\n"enable_single_replica_compaction" = "false",\n"enable_mow_light_delete" = "false"\n); -- !select -- 1 1 30 @@ -36,11 +36,11 @@ show_create_table_and_views_view CREATE VIEW `show_create_table_and_views_view` 300 1 -- !show -- -show_create_table_and_views_table CREATE TABLE `show_create_table_and_views_table` (\n `user_id` LARGEINT NOT NULL,\n `good_id` LARGEINT NOT NULL,\n `cost` BIGINT SUM NULL DEFAULT "0"\n) ENGINE=OLAP\nAGGREGATE KEY(`user_id`, `good_id`)\nPARTITION BY RANGE(`good_id`)\n(PARTITION p1 VALUES [("-170141183460469231731687303715884105728"), ("100")),\nPARTITION p2 VALUES [("100"), ("200")),\nPARTITION p3 VALUES [("200"), ("300")),\nPARTITION p4 VALUES [("300"), ("400")),\nPARTITION p5 VALUES [("400"), ("500")),\nPARTITION p6 VALUES [("500"), ("600")),\nPARTITION p7 VALUES [("600"), (MAXVALUE)))\nDISTRIBUTED BY HASH(`user_id`) BUCKETS 2\nPROPERTIES (\n"replication_allocation" = "tag.location.default: 1",\n"is_being_synced" = "false",\n"storage_medium" = "hdd",\n"storage_format" = "V2",\n"light_schema_change" = "true",\n"disable_auto_compaction" = "false",\n"binlog.enable" = "false",\n"binlog.ttl_seconds" = "86400",\n"binlog.max_bytes" = "9223372036854775807",\n"binlog.max_history_nums" = "9223372036854775807",\n"enable_single_replica_compaction" = "false"\n); +show_create_table_and_views_table CREATE TABLE `show_create_table_and_views_table` (\n `user_id` LARGEINT NOT NULL,\n `good_id` LARGEINT NOT NULL,\n `cost` BIGINT SUM NULL DEFAULT "0"\n) ENGINE=OLAP\nAGGREGATE KEY(`user_id`, `good_id`)\nPARTITION BY RANGE(`good_id`)\n(PARTITION p1 VALUES [("-170141183460469231731687303715884105728"), ("100")),\nPARTITION p2 VALUES [("100"), ("200")),\nPARTITION p3 VALUES [("200"), ("300")),\nPARTITION p4 VALUES [("300"), ("400")),\nPARTITION p5 VALUES [("400"), ("500")),\nPARTITION p6 VALUES [("500"), ("600")),\nPARTITION p7 VALUES [("600"), (MAXVALUE)))\nDISTRIBUTED BY HASH(`user_id`) BUCKETS 2\nPROPERTIES (\n"replication_allocation" = "tag.location.default: 1",\n"is_being_synced" = "false",\n"storage_medium" = "hdd",\n"storage_format" = "V2",\n"light_schema_change" = "true",\n"disable_auto_compaction" = "false",\n"binlog.enable" = "false",\n"binlog.ttl_seconds" = "86400",\n"binlog.max_bytes" = "9223372036854775807",\n"binlog.max_history_nums" = "9223372036854775807",\n"enable_single_replica_compaction" = "false",\n"enable_mow_light_delete" = "false"\n); -- !show -- -show_create_table_and_views_like CREATE TABLE `show_create_table_and_views_like` (\n `user_id` LARGEINT NOT NULL,\n `good_id` LARGEINT NOT NULL,\n `cost` BIGINT SUM NULL DEFAULT "0"\n) ENGINE=OLAP\nAGGREGATE KEY(`user_id`, `good_id`)\nPARTITION BY RANGE(`good_id`)\n(PARTITION p1 VALUES [("-170141183460469231731687303715884105728"), ("100")),\nPARTITION p2 VALUES [("100"), ("200")),\nPARTITION p3 VALUES [("200"), ("300")),\nPARTITION p4 VALUES [("300"), ("400")),\nPARTITION p5 VALUES [("400"), ("500")),\nPARTITION p6 VALUES [("500"), ("600")),\nPARTITION p7 VALUES [("600"), (MAXVALUE)))\nDISTRIBUTED BY HASH(`user_id`) BUCKETS 2\nPROPERTIES (\n"replication_allocation" = "tag.location.default: 1",\n"is_being_synced" = "false",\n"storage_medium" = "hdd",\n"storage_format" = "V2",\n"light_schema_change" = "true",\n"disable_auto_compaction" = "false",\n"binlog.enable" = "false",\n"binlog.ttl_seconds" = "86400",\n"binlog.max_bytes" = "9223372036854775807",\n"binlog.max_history_nums" = "9223372036854775807",\n"enable_single_replica_compaction" = "false"\n); +show_create_table_and_views_like CREATE TABLE `show_create_table_and_views_like` (\n `user_id` LARGEINT NOT NULL,\n `good_id` LARGEINT NOT NULL,\n `cost` BIGINT SUM NULL DEFAULT "0"\n) ENGINE=OLAP\nAGGREGATE KEY(`user_id`, `good_id`)\nPARTITION BY RANGE(`good_id`)\n(PARTITION p1 VALUES [("-170141183460469231731687303715884105728"), ("100")),\nPARTITION p2 VALUES [("100"), ("200")),\nPARTITION p3 VALUES [("200"), ("300")),\nPARTITION p4 VALUES [("300"), ("400")),\nPARTITION p5 VALUES [("400"), ("500")),\nPARTITION p6 VALUES [("500"), ("600")),\nPARTITION p7 VALUES [("600"), (MAXVALUE)))\nDISTRIBUTED BY HASH(`user_id`) BUCKETS 2\nPROPERTIES (\n"replication_allocation" = "tag.location.default: 1",\n"is_being_synced" = "false",\n"storage_medium" = "hdd",\n"storage_format" = "V2",\n"light_schema_change" = "true",\n"disable_auto_compaction" = "false",\n"binlog.enable" = "false",\n"binlog.ttl_seconds" = "86400",\n"binlog.max_bytes" = "9223372036854775807",\n"binlog.max_history_nums" = "9223372036854775807",\n"enable_single_replica_compaction" = "false",\n"enable_mow_light_delete" = "false"\n); -- !show -- -show_create_table_and_views_like_with_rollup CREATE TABLE `show_create_table_and_views_like_with_rollup` (\n `user_id` LARGEINT NOT NULL,\n `good_id` LARGEINT NOT NULL,\n `cost` BIGINT SUM NULL DEFAULT "0"\n) ENGINE=OLAP\nAGGREGATE KEY(`user_id`, `good_id`)\nPARTITION BY RANGE(`good_id`)\n(PARTITION p1 VALUES [("-170141183460469231731687303715884105728"), ("100")),\nPARTITION p2 VALUES [("100"), ("200")),\nPARTITION p3 VALUES [("200"), ("300")),\nPARTITION p4 VALUES [("300"), ("400")),\nPARTITION p5 VALUES [("400"), ("500")),\nPARTITION p6 VALUES [("500"), ("600")),\nPARTITION p7 VALUES [("600"), (MAXVALUE)))\nDISTRIBUTED BY HASH(`user_id`) BUCKETS 2\nPROPERTIES (\n"replication_allocation" = "tag.location.default: 1",\n"is_being_synced" = "false",\n"storage_medium" = "hdd",\n"storage_format" = "V2",\n"light_schema_change" = "true",\n"disable_auto_compaction" = "false",\n"binlog.enable" = "false",\n"binlog.ttl_seconds" = "86400",\n"binlog.max_bytes" = "9223372036854775807",\n"binlog.max_history_nums" = "9223372036854775807",\n"enable_single_replica_compaction" = "false"\n); +show_create_table_and_views_like_with_rollup CREATE TABLE `show_create_table_and_views_like_with_rollup` (\n `user_id` LARGEINT NOT NULL,\n `good_id` LARGEINT NOT NULL,\n `cost` BIGINT SUM NULL DEFAULT "0"\n) ENGINE=OLAP\nAGGREGATE KEY(`user_id`, `good_id`)\nPARTITION BY RANGE(`good_id`)\n(PARTITION p1 VALUES [("-170141183460469231731687303715884105728"), ("100")),\nPARTITION p2 VALUES [("100"), ("200")),\nPARTITION p3 VALUES [("200"), ("300")),\nPARTITION p4 VALUES [("300"), ("400")),\nPARTITION p5 VALUES [("400"), ("500")),\nPARTITION p6 VALUES [("500"), ("600")),\nPARTITION p7 VALUES [("600"), (MAXVALUE)))\nDISTRIBUTED BY HASH(`user_id`) BUCKETS 2\nPROPERTIES (\n"replication_allocation" = "tag.location.default: 1",\n"is_being_synced" = "false",\n"storage_medium" = "hdd",\n"storage_format" = "V2",\n"light_schema_change" = "true",\n"disable_auto_compaction" = "false",\n"binlog.enable" = "false",\n"binlog.ttl_seconds" = "86400",\n"binlog.max_bytes" = "9223372036854775807",\n"binlog.max_history_nums" = "9223372036854775807",\n"enable_single_replica_compaction" = "false",\n"enable_mow_light_delete" = "false"\n); diff --git a/regression-test/data/unique_with_mow_p0/partial_update/test_new_partial_update_delete.out b/regression-test/data/unique_with_mow_p0/partial_update/test_new_partial_update_delete.out new file mode 100644 index 00000000000000..8599b0b7fa1dca --- /dev/null +++ b/regression-test/data/unique_with_mow_p0/partial_update/test_new_partial_update_delete.out @@ -0,0 +1,105 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !sql1 -- +1 1 1 1 1 + +-- !sql2 -- + +-- !sql3 -- +1 0 \N \N \N 1 + +-- !sql4 -- +1 2 \N \N \N + +-- !sql11 -- +1 2 \N \N \N +2 2 2 2 2 + +-- !sql12 -- + +-- !sql13 -- + +-- !sql14 -- +1 2 \N \N \N +2 2 2 2 2 + +-- !sql15 -- +2 3 2 2 2 + +-- !sql21 -- +1 1 1 1 1 + +-- !sql22 -- + +-- !sql23 -- +1 \N \N \N \N 1 + +-- !sql24 -- +1 2 \N \N \N + +-- !sql31 -- +1 2 \N \N \N +2 2 2 2 2 + +-- !sql32 -- + +-- !sql33 -- + +-- !sql34 -- +1 2 \N \N \N +2 2 2 2 2 + +-- !sql35 -- +2 3 2 2 2 + +-- !sql1 -- +1 1 1 1 1 + +-- !sql2 -- + +-- !sql3 -- +1 0 \N \N \N 1 + +-- !sql4 -- +1 2 \N \N \N + +-- !sql11 -- +1 2 \N \N \N +2 2 2 2 2 + +-- !sql12 -- + +-- !sql13 -- + +-- !sql14 -- +1 2 \N \N \N +2 2 2 2 2 + +-- !sql15 -- +2 3 2 2 2 + +-- !sql21 -- +1 1 1 1 1 + +-- !sql22 -- + +-- !sql23 -- +1 \N \N \N \N 1 + +-- !sql24 -- +1 2 \N \N \N + +-- !sql31 -- +1 2 \N \N \N +2 2 2 2 2 + +-- !sql32 -- + +-- !sql33 -- + +-- !sql34 -- +1 2 \N \N \N +2 2 2 2 2 + +-- !sql35 -- +2 3 2 2 2 + diff --git a/regression-test/data/unique_with_mow_p0/partial_update/test_partial_update_after_delete.out b/regression-test/data/unique_with_mow_p0/partial_update/test_partial_update_after_delete.out new file mode 100644 index 00000000000000..a7b2a03456ab05 --- /dev/null +++ b/regression-test/data/unique_with_mow_p0/partial_update/test_partial_update_after_delete.out @@ -0,0 +1,13 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !select1 -- +1 2 \N + +-- !select2 -- +1 2 \N + +-- !select1 -- +1 2 \N + +-- !select2 -- +1 2 \N + diff --git a/regression-test/suites/index_p0/test_bitmap_index.groovy b/regression-test/suites/index_p0/test_bitmap_index.groovy index e6f32462de42e1..3344f8557f3be4 100644 --- a/regression-test/suites/index_p0/test_bitmap_index.groovy +++ b/regression-test/suites/index_p0/test_bitmap_index.groovy @@ -473,7 +473,7 @@ suite("test_bitmap_index") { qt_sql "select count(*) from ${tbName5}; " qt_sql "select count(*) from ${tbName5} where vid='123'; " qt_sql "select count(*) from ${tbName5} where create_time>='2023-08-25 10:00:00';" - qt_sql "select count(CASE when vid='123' then 1 else null end) from ${tbName5} where vid='123';" + // qt_sql "select count(CASE when vid='123' then 1 else null end) from ${tbName5} where vid='123';" qt_sql "select * from ${tbName5} where vid='123' order by create_time;" sql "DROP INDEX IF EXISTS index1 ON ${tbName5};" diff --git a/regression-test/suites/unique_with_mow_p0/partial_update/test_new_partial_update_delete.groovy b/regression-test/suites/unique_with_mow_p0/partial_update/test_new_partial_update_delete.groovy new file mode 100644 index 00000000000000..cd8a77fad2e764 --- /dev/null +++ b/regression-test/suites/unique_with_mow_p0/partial_update/test_new_partial_update_delete.groovy @@ -0,0 +1,301 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +suite('test_new_partial_update_delete') { + + String db = context.config.getDbNameByFile(context.file) + sql "select 1;" // to create database + + for (def use_row_store : [false, true]) { + logger.info("current params: use_row_store: ${use_row_store}") + + connect(user = context.config.jdbcUser, password = context.config.jdbcPassword, url = context.config.jdbcUrl) { + sql "use ${db};" + + sql "set enable_nereids_planner=true" + sql "set enable_fallback_to_original_planner=false" + + try { + def tableMorName1 = "test_new_partial_update_mor_delete1" + sql "DROP TABLE IF EXISTS ${tableMorName1};" + sql """ CREATE TABLE IF NOT EXISTS ${tableMorName1} ( + `k1` int NOT NULL, + `c1` int, + `c2` int, + `c3` int, + `c4` int + )UNIQUE KEY(k1) + DISTRIBUTED BY HASH(k1) BUCKETS 1 + PROPERTIES ( + "disable_auto_compaction" = "true", + "enable_unique_key_merge_on_write" = "false", + "enable_mow_light_delete" = "true", + "replication_num" = "1", + "store_row_column" = "${use_row_store}"); """ + } catch (Exception e) { + log.info(e.getMessage()) + assertTrue(e.getMessage().contains('enable_mow_light_delete property is only supported for unique merge-on-write table')) + } + + try { + def tableMorName2 = "test_new_partial_update_mor_delete2" + sql "DROP TABLE IF EXISTS ${tableMorName2};" + sql """ CREATE TABLE IF NOT EXISTS ${tableMorName2} ( + `k1` int NOT NULL, + `c1` int, + `c2` int, + `c3` int, + `c4` int + )UNIQUE KEY(k1) + DISTRIBUTED BY HASH(k1) BUCKETS 1 + PROPERTIES ( + "disable_auto_compaction" = "true", + "enable_unique_key_merge_on_write" = "false", + "replication_num" = "1", + "store_row_column" = "${use_row_store}"); """ + sql """alter table ${tableMorName2} set ("enable_mow_light_delete"="true")""" + } catch (Exception e) { + log.info(e.getMessage()) + assertTrue(e.getMessage().contains('enable_mow_light_delete property is only supported for unique merge-on-write table')) + } + + def tableName1 = "test_new_partial_update_delete1" + sql "DROP TABLE IF EXISTS ${tableName1};" + sql """ CREATE TABLE IF NOT EXISTS ${tableName1} ( + `k1` int NOT NULL, + `c1` int NOT NULL, + `c2` int, + `c3` int, + `c4` int + )UNIQUE KEY(k1) + DISTRIBUTED BY HASH(k1) BUCKETS 1 + PROPERTIES ( + "disable_auto_compaction" = "true", + "enable_unique_key_merge_on_write" = "true", + "replication_num" = "1", + "store_row_column" = "${use_row_store}"); """ + + def output1 = sql "show create table ${tableName1}" + assertTrue output1[0][1].contains("\"enable_mow_light_delete\" = \"false\""); + sql "insert into ${tableName1} values(1,1,1,1,1)" + // 1,1,1,1,1 + qt_sql1 "select * from ${tableName1} order by k1;" + sql "delete from ${tableName1} where k1 = 1" + // empty + qt_sql2 "select * from ${tableName1} order by k1;" + sql "set show_hidden_columns = true;" + // 1,1,1,1,1,1 + qt_sql3 "select k1,c1,c2,c3,c4,__DORIS_DELETE_SIGN__ from ${tableName1} order by k1;" + sql "set show_hidden_columns = false;" + sql "set enable_unique_key_partial_update=true;" + sql "set enable_insert_strict=false;" + sql "insert into ${tableName1} (k1,c1) values(1,2)" + // 1,2,NULL,NULL,NULL + qt_sql4 "select * from ${tableName1} order by k1;" + + + + sql """alter table ${tableName1} set ("enable_mow_light_delete"="true") """ + sql "set enable_unique_key_partial_update=false;" + sql "set enable_insert_strict=true;" + def output2 = sql "show create table ${tableName1}" + assertTrue output2[0][1].contains("\"enable_mow_light_delete\" = \"true\""); + sql "insert into ${tableName1} values(2,2,2,2,2)" + // 1,2,NULL,NULL,NULL + // 2,2,2,2,2 + qt_sql11 "select * from ${tableName1} order by k1;" + sql "delete from ${tableName1} where k1 <= 2" + // empty + qt_sql12 "select * from ${tableName1} order by k1;" + sql "set show_hidden_columns = true;" + // empty + qt_sql13 "select * from ${tableName1} order by k1;" + sql "set show_hidden_columns = false;" + sql "set skip_delete_predicate = true;" + // 1,2,NULL,NULL,NULL + // 2,2,2,2,2 + qt_sql14 "select * from ${tableName1} order by k1;" + sql "set skip_delete_predicate = false;" + sql "set enable_unique_key_partial_update=true;" + sql "set enable_insert_strict=false;" + sql "insert into ${tableName1} (k1,c1) values(2,3)" + // 2,3,2,2,2 + qt_sql15 "select * from ${tableName1} order by k1;" + sql "set enable_unique_key_partial_update=false;" + sql "set enable_insert_strict=true;" + + sql "drop table if exists ${tableName1};" + + + + // old planner + try { + def tableMorName3 = "test_new_partial_update_mor_delete3" + sql "DROP TABLE IF EXISTS ${tableMorName3};" + sql """ CREATE TABLE IF NOT EXISTS ${tableMorName3} ( + `k1` int NOT NULL, + `c1` int, + `c2` int, + `c3` int, + `c4` int + )UNIQUE KEY(k1) + DISTRIBUTED BY HASH(k1) BUCKETS 1 + PROPERTIES ( + "disable_auto_compaction" = "true", + "enable_unique_key_merge_on_write" = "false", + "enable_mow_light_delete" = "true", + "replication_num" = "1", + "store_row_column" = "${use_row_store}"); """ + } catch (Exception e) { + log.info(e.getMessage()) + assertTrue(e.getMessage().contains('enable_mow_light_delete property is only supported for unique merge-on-write table')) + } + + try { + def tableMorName4 = "test_new_partial_update_mor_delete4" + sql "DROP TABLE IF EXISTS ${tableMorName4};" + sql """ CREATE TABLE IF NOT EXISTS ${tableMorName4} ( + `k1` int NOT NULL, + `c1` int, + `c2` int, + `c3` int, + `c4` int + )UNIQUE KEY(k1) + DISTRIBUTED BY HASH(k1) BUCKETS 1 + PROPERTIES ( + "disable_auto_compaction" = "true", + "enable_unique_key_merge_on_write" = "false", + "replication_num" = "1", + "store_row_column" = "${use_row_store}"); """ + sql """alter table ${tableMorName4} set ("enable_mow_light_delete"="true")""" + } catch (Exception e) { + log.info(e.getMessage()) + assertTrue(e.getMessage().contains('enable_mow_light_delete property is only supported for unique merge-on-write table')) + } + sql "set enable_nereids_planner=false" + def tableName2 = "test_new_partial_update_delete2" + sql "DROP TABLE IF EXISTS ${tableName2};" + sql """ CREATE TABLE IF NOT EXISTS ${tableName2} ( + `k1` int NOT NULL, + `c1` int, + `c2` int, + `c3` int, + `c4` int + )UNIQUE KEY(k1) + DISTRIBUTED BY HASH(k1) BUCKETS 1 + PROPERTIES ( + "disable_auto_compaction" = "true", + "replication_num" = "1", + "enable_unique_key_merge_on_write" = "true", + "store_row_column" = "${use_row_store}"); """ + + def output3 = sql "show create table ${tableName2}" + assertTrue output3[0][1].contains("\"enable_mow_light_delete\" = \"false\""); + sql "insert into ${tableName2} values(1,1,1,1,1)" + // 1,1,1,1,1 + qt_sql21 "select * from ${tableName2} order by k1;" + sql "delete from ${tableName2} where k1 = 1" + // empty + qt_sql22 "select * from ${tableName2} order by k1;" + sql "set show_hidden_columns = true;" + // 1,1,1,1,1,1 + qt_sql23 "select k1,c1,c2,c3,c4,__DORIS_DELETE_SIGN__ from ${tableName2} order by k1;" + sql "set show_hidden_columns = false;" + sql "set enable_unique_key_partial_update=true;" + sql "set enable_insert_strict=false;" + sql "insert into ${tableName2} (k1,c1) values(1,2)" + // 1,2,NULL,NULL,NULL + qt_sql24 "select * from ${tableName2} order by k1;" + + + + sql """alter table ${tableName2} set ("enable_mow_light_delete"="true") """ + sql "set enable_unique_key_partial_update=false;" + sql "set enable_insert_strict=true;" + def output4 = sql "show create table ${tableName2}" + assertTrue output4[0][1].contains("\"enable_mow_light_delete\" = \"true\""); + sql "insert into ${tableName2} values(2,2,2,2,2)" + // 1,2,NULL,NULL,NULL + // 2,2,2,2,2 + qt_sql31 "select * from ${tableName2} order by k1;" + sql "delete from ${tableName2} where k1 <= 2" + // empty + qt_sql32 "select * from ${tableName2} order by k1;" + sql "set show_hidden_columns = true;" + // empty + qt_sql33 "select * from ${tableName2} order by k1;" + sql "set show_hidden_columns = false;" + sql "set skip_delete_predicate = true;" + // 1,2,NULL,NULL,NULL + // 2,2,2,2,2 + qt_sql34 "select * from ${tableName2} order by k1;" + sql "set skip_delete_predicate = false;" + sql "set enable_unique_key_partial_update=true;" + sql "set enable_insert_strict=false;" + sql "insert into ${tableName2} (k1,c1) values(2,3)" + // 2,3,2,2,2 + qt_sql35 "select * from ${tableName2} order by k1;" + sql "set enable_unique_key_partial_update=false;" + sql "set enable_insert_strict=true;" + + sql "drop table if exists ${tableName2};" + } + } + + connect(user = context.config.jdbcUser, password = context.config.jdbcPassword, url = context.config.jdbcUrl) { + sql "use ${db};" + try { + def tableAggName = "test_new_partial_update_agg_delete" + sql "DROP TABLE IF EXISTS ${tableAggName};" + sql """ CREATE TABLE IF NOT EXISTS ${tableAggName} ( + `k1` int NOT NULL, + `c1` int replace, + `c2` int replace, + `c3` int replace, + `c4` int replace + )AGGREGATE KEY(k1) + DISTRIBUTED BY HASH(k1) BUCKETS 1 + PROPERTIES ( + "disable_auto_compaction" = "true", + "enable_mow_light_delete" = "true", + "replication_num" = "1"); """ + } catch (Exception e) { + log.info(e.getMessage()) + assertTrue(e.getMessage().contains('enable_mow_light_delete property is only supported for unique merge-on-write table')) + } + + try { + def tableDupName = "test_new_partial_update_dup_delete" + sql "DROP TABLE IF EXISTS ${tableDupName};" + sql """ CREATE TABLE IF NOT EXISTS ${tableDupName} ( + `k1` int NOT NULL, + `c1` int, + `c2` int, + `c3` int, + `c4` int + )DUPLICATE KEY(k1) + DISTRIBUTED BY HASH(k1) BUCKETS 1 + PROPERTIES ( + "disable_auto_compaction" = "true", + "enable_mow_light_delete" = "true", + "replication_num" = "1"); """ + } catch (Exception e) { + log.info(e.getMessage()) + assertTrue(e.getMessage().contains('enable_mow_light_delete property is only supported for unique merge-on-write table')) + } + } +} diff --git a/regression-test/suites/unique_with_mow_p0/partial_update/test_partial_update_after_delete.groovy b/regression-test/suites/unique_with_mow_p0/partial_update/test_partial_update_after_delete.groovy new file mode 100644 index 00000000000000..41cebac66bd12c --- /dev/null +++ b/regression-test/suites/unique_with_mow_p0/partial_update/test_partial_update_after_delete.groovy @@ -0,0 +1,79 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +suite("test_partial_update_after_delete", "p0") { + + String db = context.config.getDbNameByFile(context.file) + sql "select 1;" // to create database + + for (def use_row_store : [false, true]) { + logger.info("current params: use_row_store: ${use_row_store}") + + connect(user = context.config.jdbcUser, password = context.config.jdbcPassword, url = context.config.jdbcUrl) { + sql "use ${db};" + sql "SET enable_nereids_planner=true;" + sql "SET enable_fallback_to_original_planner=false;" + sql "set enable_unique_key_partial_update=false;" + sql "set enable_insert_strict=true;" + def tableName1 = "test_partial_update_after_delete1" + sql "DROP TABLE IF EXISTS ${tableName1};" + sql """ CREATE TABLE IF NOT EXISTS ${tableName1} ( + `k1` INT NULL, + `v1` INT NULL, + `v2` INT NULL + )UNIQUE KEY(k1) + DISTRIBUTED BY HASH(k1) BUCKETS 1 + PROPERTIES ( + "enable_unique_key_merge_on_write" = "true", + "disable_auto_compaction" = "true", + "replication_num" = "1", + "store_row_column" = "${use_row_store}"); """ + + sql "insert into ${tableName1} values(1,1,1);" + sql "delete from ${tableName1} where k1=1;" + sql "set enable_unique_key_partial_update=true;" + sql "set enable_insert_strict=false;" + sql "insert into ${tableName1}(k1, v1) values(1,2);" + qt_select1 "select * from ${tableName1};" + + sql "set enable_unique_key_partial_update=false;" + sql "set enable_insert_strict=true;" + sql "SET enable_nereids_planner=false;" + sql "SET enable_fallback_to_original_planner=false;" + def tableName2 = "test_partial_update_after_delete2" + sql "DROP TABLE IF EXISTS ${tableName2};" + sql """ CREATE TABLE IF NOT EXISTS ${tableName2} ( + `k1` INT NULL, + `v1` INT NULL, + `v2` INT NULL + )UNIQUE KEY(k1) + DISTRIBUTED BY HASH(k1) BUCKETS 1 + PROPERTIES ( + "enable_unique_key_merge_on_write" = "true", + "disable_auto_compaction" = "true", + "replication_num" = "1", + "store_row_column" = "${use_row_store}"); """ + + sql "insert into ${tableName2} values(1,1,1);" + sql "delete from ${tableName2} where k1=1;" + sql "set enable_unique_key_partial_update=true;" + sql "set enable_insert_strict=false;" + sql "insert into ${tableName2}(k1, v1) values(1,2);" + qt_select2 "select * from ${tableName2};" + } + } +}