This is an automated email from the ASF dual-hosted git repository. dataroaring pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push: new 6a31e0c86e3 [fix](cluster key) fix cluster key update (#44413) 6a31e0c86e3 is described below commit 6a31e0c86e3ebab3fb6bbd10292784f19674d425 Author: meiyi <me...@selectdb.com> AuthorDate: Fri Nov 22 19:46:28 2024 +0800 [fix](cluster key) fix cluster key update (#44413) for mow with cluster key, update may get: ``` mysql> update t2_cluster_key set b = 22 where c = 2; ERROR 1105 (HY000): errCode = 2, detailMessage = Column has no default value, column=c ``` --- .../trees/plans/commands/UpdateCommand.java | 3 +- .../partial_update/test_mix_partial_update.out | 36 +++++++++--------- .../test_partial_update_with_update_stmt.out | 12 +++--- .../data/unique_with_mow_c_p0/test_update.out | 6 +++ .../test_partial_update_with_update_stmt.groovy | 18 ++++----- .../suites/unique_with_mow_c_p0/test_update.groovy | 43 ++++++++++++++++++++++ 6 files changed, 82 insertions(+), 36 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/UpdateCommand.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/UpdateCommand.java index 51cfbf0b272..ada4ca9035c 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/UpdateCommand.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/UpdateCommand.java @@ -161,7 +161,8 @@ public class UpdateCommand extends Command implements ForwardWithSync, Explainab boolean isPartialUpdate = targetTable.getEnableUniqueKeyMergeOnWrite() && selectItems.size() < targetTable.getColumns().size() && targetTable.getSequenceCol() == null - && partialUpdateColNameToExpression.size() <= targetTable.getFullSchema().size() * 3 / 10; + && partialUpdateColNameToExpression.size() <= targetTable.getFullSchema().size() * 3 / 10 + && !targetTable.isUniqKeyMergeOnWriteWithClusterKeys(); List<String> partialUpdateColNames = new ArrayList<>(); List<NamedExpression> partialUpdateSelectItems = new ArrayList<>(); diff --git a/regression-test/data/unique_with_mow_c_p0/partial_update/test_mix_partial_update.out b/regression-test/data/unique_with_mow_c_p0/partial_update/test_mix_partial_update.out index cb5c64e0d81..ce568111469 100644 --- a/regression-test/data/unique_with_mow_c_p0/partial_update/test_mix_partial_update.out +++ b/regression-test/data/unique_with_mow_c_p0/partial_update/test_mix_partial_update.out @@ -97,8 +97,8 @@ 2 -- !select_C -- -1 \N \N \N -2 \N \N \N +1 1 1 {"a":100, "b":100} +2 2 2 {"a":200, "b":200} -- !select_CC -- 1 @@ -107,8 +107,8 @@ 2 -- !select_D -- -1 \N \N \N -2 \N \N \N +1 1 1 {"a":100, "b":100} +2 2 2 {"a":200, "b":200} 3 3 3 {"a":300, "b":300} -- !select_DD -- @@ -118,8 +118,8 @@ 1 -- !select_E -- -1 \N \N \N -2 \N \N \N +1 1 1 {"a":100, "b":100} +2 2 2 {"a":200, "b":200} 3 3 3 {"a":300, "b":300} 4 4 4 {"a":400, "b":400} @@ -148,7 +148,7 @@ 1 -- !select_C -- -1 \N \N \N +1 1 1 {"a":100, "b":100} -- !select_CC -- 1 @@ -157,7 +157,7 @@ 1 -- !select_D -- -1 \N \N \N +1 1 1 {"a":100, "b":100} 3 3 3 {"a":300, "b":300} -- !select_DD -- @@ -167,7 +167,7 @@ 1 -- !select_E -- -1 \N \N \N +1 1 1 {"a":100, "b":100} 3 3 3 {"a":300, "b":300} 4 4 4 {"a":400, "b":400} @@ -275,8 +275,8 @@ 2 -- !select_C -- -1 \N \N \N -2 \N \N \N +1 1 1 {"a":100, "b":100} +2 2 2 {"a":200, "b":200} -- !select_CC -- 1 @@ -285,8 +285,8 @@ 2 -- !select_D -- -1 \N \N \N -2 \N \N \N +1 1 1 {"a":100, "b":100} +2 2 2 {"a":200, "b":200} 3 3 3 {"a":300, "b":300} -- !select_DD -- @@ -296,8 +296,8 @@ 1 -- !select_E -- -1 \N \N \N -2 \N \N \N +1 1 1 {"a":100, "b":100} +2 2 2 {"a":200, "b":200} 3 3 3 {"a":300, "b":300} 4 4 4 {"a":400, "b":400} @@ -326,7 +326,7 @@ 1 -- !select_C -- -1 \N \N \N +1 1 1 {"a":100, "b":100} -- !select_CC -- 1 @@ -335,7 +335,7 @@ 1 -- !select_D -- -1 \N \N \N +1 1 1 {"a":100, "b":100} 3 3 3 {"a":300, "b":300} -- !select_DD -- @@ -345,7 +345,7 @@ 1 -- !select_E -- -1 \N \N \N +1 1 1 {"a":100, "b":100} 3 3 3 {"a":300, "b":300} 4 4 4 {"a":400, "b":400} diff --git a/regression-test/data/unique_with_mow_c_p0/partial_update/test_partial_update_with_update_stmt.out b/regression-test/data/unique_with_mow_c_p0/partial_update/test_partial_update_with_update_stmt.out index 6e06f6aeeab..43c2e32104a 100644 --- a/regression-test/data/unique_with_mow_c_p0/partial_update/test_partial_update_with_update_stmt.out +++ b/regression-test/data/unique_with_mow_c_p0/partial_update/test_partial_update_with_update_stmt.out @@ -1,17 +1,17 @@ -- This file is automatically generated. You should know what you did if you want to edit this -- !select_default -- -1 doris 1000 123 1 +1 doris 4000 123 1 2 doris2 2000 223 1 -- !select_join -- -1 doris 1000 123 1 -2 doris4 8000 \N 4321 +1 doris 4000 123 1 +2 doris4 8000 223 1 -- !select_default -- -1 doris 1000 123 1 +1 doris 4000 123 1 2 doris2 2000 223 1 -- !select_join -- -1 doris 1000 123 1 -2 doris4 8000 \N 4321 +1 doris 4000 123 1 +2 doris4 8000 223 1 diff --git a/regression-test/data/unique_with_mow_c_p0/test_update.out b/regression-test/data/unique_with_mow_c_p0/test_update.out new file mode 100644 index 00000000000..d1eedc98b1e --- /dev/null +++ b/regression-test/data/unique_with_mow_c_p0/test_update.out @@ -0,0 +1,6 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !sql -- +10 200 3 +11 200 3 +12 22 32 + diff --git a/regression-test/suites/unique_with_mow_c_p0/partial_update/test_partial_update_with_update_stmt.groovy b/regression-test/suites/unique_with_mow_c_p0/partial_update/test_partial_update_with_update_stmt.groovy index 88d6d1ccc46..0a29b382b30 100644 --- a/regression-test/suites/unique_with_mow_c_p0/partial_update/test_partial_update_with_update_stmt.groovy +++ b/regression-test/suites/unique_with_mow_c_p0/partial_update/test_partial_update_with_update_stmt.groovy @@ -57,10 +57,9 @@ suite("test_primary_key_partial_update_with_update_stmt", "p0") { """ // case 1: partially update normally - test { - sql """ update ${tableName} set score = 4000 where id = 1 """ - exception "Column has no default value" - } + sql """ + update ${tableName} set score = 4000 where id = 1 + """ sql "sync" @@ -69,15 +68,12 @@ suite("test_primary_key_partial_update_with_update_stmt", "p0") { """ // case 2: partially update non-exist key - test { - def result1 = sql """ + def result1 = sql """ update ${tableName} set score = 2000 where id = 3 """ - /*assertTrue(result1.size() == 1) - assertTrue(result1[0].size() == 1) - assertTrue(result1[0][0] == 0, "Query OK, 0 rows affected")*/ - exception "Column has no default value" - } + assertTrue(result1.size() == 1) + assertTrue(result1[0].size() == 1) + assertTrue(result1[0][0] == 0, "Query OK, 0 rows affected") sql "sync" diff --git a/regression-test/suites/unique_with_mow_c_p0/test_update.groovy b/regression-test/suites/unique_with_mow_c_p0/test_update.groovy new file mode 100644 index 00000000000..b062da54516 --- /dev/null +++ b/regression-test/suites/unique_with_mow_c_p0/test_update.groovy @@ -0,0 +1,43 @@ +// 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_update") { + def tableName = "test_update" + sql """ DROP TABLE IF EXISTS ${tableName} """ + onFinish { + try_sql("DROP TABLE IF EXISTS ${tableName}") + } + + sql """ + CREATE TABLE `$tableName` ( + `a` int NOT NULL, + `b` int NOT NULL, + `c` int NOT NULL + ) ENGINE=OLAP + UNIQUE KEY(`a`) + CLUSTER BY (`b`) + DISTRIBUTED BY HASH(`a`) BUCKETS 1 + PROPERTIES ( + "replication_num" = "1", + "enable_unique_key_merge_on_write" = "true" + ); + """ + + sql """ insert into $tableName values(10, 20, 3), (11, 21, 3), (12, 22, 32); """ + sql """ update $tableName set b = 200 where c = 3; """ + order_qt_sql "select * from $tableName" +} --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org