From e769c8f45c86a517eb3c45a1c3214d031e655f05 Mon Sep 17 00:00:00 2001 From: bobhan1 Date: Wed, 9 Aug 2023 16:23:30 +0800 Subject: [PATCH] upadte --- .../org/apache/doris/analysis/DeleteStmt.java | 12 ++-- .../org/apache/doris/load/DeleteHandler.java | 3 - .../data/delete_p0/test_delete_on_value.out | 55 +++++++++++++++++++ .../delete_p0/test_delete_on_value.groovy | 41 ++++++-------- 4 files changed, 79 insertions(+), 32 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/DeleteStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/DeleteStmt.java index f3699af3d501446..c9c6155c7e2b267 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/DeleteStmt.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/DeleteStmt.java @@ -324,10 +324,14 @@ private void checkDeleteConditions() throws AnalysisException { // Due to rounding errors, most floating-point numbers end up being slightly imprecise, // it also means that numbers expected to be equal often differ slightly, so we do not allow compare with // floating-point numbers, floating-point number not allowed in where clause - if (!column.isKey() && table.getKeysType() != KeysType.DUP_KEYS - || column.getDataType().isFloatingPointType()) { - throw new AnalysisException("Column[" + columnName + "] is not key column or storage model " - + "is not duplicate or column type is float or double."); + if (column.getDataType().isFloatingPointType()) { + throw new AnalysisException("Column[" + columnName + "] type is float or double."); + } + if (!column.isKey()) { + if (table.getKeysType() == KeysType.AGG_KEYS) { + throw new AnalysisException("delete predicate on value column only supports Unique table and" + + "Duplicate table" + "Table[" + table.getName() + "] is Aggregate table."); + } } if (condition instanceof BinaryPredicate) { diff --git a/fe/fe-core/src/main/java/org/apache/doris/load/DeleteHandler.java b/fe/fe-core/src/main/java/org/apache/doris/load/DeleteHandler.java index 49b52ffd289aa27..289c5f2289327a2 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/load/DeleteHandler.java +++ b/fe/fe-core/src/main/java/org/apache/doris/load/DeleteHandler.java @@ -689,11 +689,8 @@ private void checkDeleteV2(OlapTable table, List partitions, // it also means that numbers expected to be equal often differ slightly, so we do not allow compare with // floating-point numbers, floating-point number not allowed in where clause if (column.getDataType().isFloatingPointType()) { - // ErrorReport.reportDdlException(ErrorCode.ERR_NOT_KEY_COLUMN, columnName); throw new DdlException("Column[" + columnName + "] type is float or double."); } - LOG.warn("table {}, keysType: {}, column: {}, isSequenceColumn: {}, isKey: {}", table.getName(), - table.getKeysType(), columnName, column.isSequenceColumn(), column.isKey()); if (!column.isKey()) { if (table.getKeysType() == KeysType.AGG_KEYS) { throw new DdlException("delete predicate on value column only supports Unique table and" 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 6b4f554128fbe09..17745f342f021ad 100644 --- a/regression-test/data/delete_p0/test_delete_on_value.out +++ b/regression-test/data/delete_p0/test_delete_on_value.out @@ -10,3 +10,58 @@ 8 8 8 9 9 9 +-- !sql -- +1 1 1 +2 2 2 +3 3 3 +5 5 5 +6 6 6 +7 7 7 +8 8 8 +9 9 9 + +-- !sql -- +1 1 1 +2 2 2 +8 8 8 +9 9 9 + +-- !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 + +-- !sql -- +1 1 1 +2 2 2 +4 4 4 +5 5 5 +8 8 8 +9 9 9 + +-- !sql -- +1 1 1 +2 2 2 +4 4 4 +8 8 8 +9 9 9 + +-- !sql -- +1 1 1 0 +2 2 2 0 +3 3 3 0 +4 4 4 0 +4 4 4 0 +5 5 5 0 +5 5 5 0 +6 6 6 0 +7 7 7 0 +8 8 8 0 +9 9 9 0 + diff --git a/regression-test/suites/delete_p0/test_delete_on_value.groovy b/regression-test/suites/delete_p0/test_delete_on_value.groovy index 6117313ea0bb42f..e77dfe1f7690df5 100644 --- a/regression-test/suites/delete_p0/test_delete_on_value.groovy +++ b/regression-test/suites/delete_p0/test_delete_on_value.groovy @@ -16,6 +16,9 @@ // under the License. suite("test_delete_on_value") { + sql 'set enable_nereids_planner=false' + sql "set experimental_enable_nereids_planner=false;" + sql 'set enable_nereids_dml=false' def tableName = "test_delete_on_value" sql """ DROP TABLE IF EXISTS ${tableName} """ @@ -32,33 +35,21 @@ suite("test_delete_on_value") { "enable_unique_key_merge_on_write" = "true" );""" sql """ insert into ${tableName} values(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5),(6,6,6),(7,7,7),(8,8,8),(9,9,9); """ - qt_sql "select * from ${tableName} order by x;" + sql "set skip_delete_sign=true;" + qt_sql "select * from ${tableName} order by x,y,z;" sql "delete from ${tableName} where y=4;" - qt_sql "select * from ${tableName} order by x;" + qt_sql "select * from ${tableName} order by x,y,z;" sql "delete from ${tableName} where z>=3 and z<=7;" - qt_sql "select * from ${tableName} order by x;" + qt_sql "select * from ${tableName} order by x,y,z;" + sql "set skip_delete_predicate=true;" + qt_sql "select x,y,z,__DORIS_DELETE_SIGN__ from ${tableName} order by x,y,z,__DORIS_DELETE_SIGN__;" + sql "set skip_delete_predicate=false;" sql "insert into ${tableName} values(4,4,4),(5,5,5);" - qt_sql "select * from ${tableName} order by x;" + qt_sql "select * from ${tableName} order by x,y,z;" sql "delete from ${tableName} where y=5;" - qt_sql "select * from ${tableName} order by x;" - - - def tableName2 = "test_delete_on_value2" - sql """ DROP TABLE IF EXISTS ${tableName2} """ - sql """ CREATE TABLE ${tableName2} ( - `x` BIGINT NOT NULL, - `y` BIGINT REPLACE_IF_NOT_NULL NULL, - `z` BIGINT REPLACE_IF_NOT_NULL NULL) - ENGINE=OLAP - AGGREGATE KEY(`x`) - COMMENT 'OLAP' - DISTRIBUTED BY HASH(`x`) BUCKETS 4 - PROPERTIES ( - "replication_num" = "1" - );""" - sql """ insert into ${tableName2} values(1,1,1); """ - test { - sql "delete from ${tableName} where y=4;" - exception "delete predicate on value column only supports Unique table" - } + qt_sql "select * from ${tableName} order by x,y,z;" + sql "set skip_storage_engine_merge=true;" + sql "set skip_delete_bitmap=true;" + sql "set skip_delete_predicate=true;" + qt_sql "select x,y,z,__DORIS_DELETE_SIGN__ from ${tableName} order by x,y,z,__DORIS_DELETE_SIGN__;" }