Skip to content

Commit

Permalink
upadte
Browse files Browse the repository at this point in the history
  • Loading branch information
bobhan1 committed Aug 9, 2023
1 parent f8af846 commit e769c8f
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -689,11 +689,8 @@ private void checkDeleteV2(OlapTable table, List<Partition> 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"
Expand Down
55 changes: 55 additions & 0 deletions regression-test/data/delete_p0/test_delete_on_value.out
Original file line number Diff line number Diff line change
Expand Up @@ -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

41 changes: 16 additions & 25 deletions regression-test/suites/delete_p0/test_delete_on_value.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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} """
Expand All @@ -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__;"
}

0 comments on commit e769c8f

Please sign in to comment.