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 d5d7aed2d5c [fix](partial update) only unique table with MOW insert with target columns can consider be a partial update (#33656) d5d7aed2d5c is described below commit d5d7aed2d5c4d2c24ef770ed94cd4f8c3ccdcf58 Author: xueweizhang <zxw520bl...@163.com> AuthorDate: Sat Apr 27 14:06:07 2024 +0800 [fix](partial update) only unique table with MOW insert with target columns can consider be a partial update (#33656) * [fix](partial update) only unique table with MOW insert with target columns can consider be a partial update Signed-off-by: nextdreamblue <zxw520bl...@163.com> * fix 1 Signed-off-by: nextdreamblue <zxw520bl...@163.com> --------- Signed-off-by: nextdreamblue <zxw520bl...@163.com> --- .../java/org/apache/doris/analysis/NativeInsertStmt.java | 10 +++++++--- .../test_partial_update_native_insert_stmt.out | 8 ++++++++ .../nereids_p0/insert_into_table/partial_update.groovy | 2 +- .../insert_into_table/partial_update_complex.groovy | 2 +- .../test_partial_update_native_insert_stmt.groovy | 12 +++++------- .../test_partial_update_native_insert_stmt_complex.groovy | 2 +- 6 files changed, 23 insertions(+), 13 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/NativeInsertStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/NativeInsertStmt.java index 3cfc3341ae0..c33eba2e57c 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/NativeInsertStmt.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/NativeInsertStmt.java @@ -1288,12 +1288,16 @@ public class NativeInsertStmt extends InsertStmt { if (olapTable.getKeysType() != KeysType.UNIQUE_KEYS) { return; } + // when enable_unique_key_partial_update = true, + // only unique table with MOW insert with target columns can consider be a partial update, + // and unique table without MOW, insert will be like a normal insert. + // when enable_unique_key_partial_update = false, + // unique table with MOW, insert will be a normal insert, and column that not set will insert default value. if (!olapTable.getEnableUniqueKeyMergeOnWrite()) { - throw new UserException("Partial update is only allowed on unique table with merge-on-write enabled."); + return; } if (hasEmptyTargetColumns) { - throw new AnalysisException("You must explicitly specify the columns to be updated when " - + "updating partial columns using the INSERT statement."); + return; } for (Column col : olapTable.getFullSchema()) { boolean exists = false; diff --git a/regression-test/data/unique_with_mow_p0/partial_update/test_partial_update_native_insert_stmt.out b/regression-test/data/unique_with_mow_p0/partial_update/test_partial_update_native_insert_stmt.out index 3ee9fbcb760..3c2ae8804c1 100644 --- a/regression-test/data/unique_with_mow_p0/partial_update/test_partial_update_native_insert_stmt.out +++ b/regression-test/data/unique_with_mow_p0/partial_update/test_partial_update_native_insert_stmt.out @@ -145,3 +145,11 @@ 10000 2017-10-01 2017-10-01T08:00:05 北京 20 0 2017-10-01T06:00 20 10 10 10000 2017-10-01 2017-10-01T09:00:05 北京 20 0 2017-10-01T07:00 15 2 2 +-- !sql -- +10000 2017-10-01 2017-10-01T08:00:05 北京 20 0 2017-10-01T06:00 20 10 10 +10000 2017-10-01 2017-10-01T09:00:05 北京 20 0 2017-10-01T07:00 15 2 2 + +-- !sql -- +10000 2017-10-01 2017-10-01T08:00:05 北京 20 0 2017-10-01T06:00 20 10 10 +10000 2017-10-01 2017-10-01T09:00:05 北京 20 0 2017-10-01T07:00 15 2 2 + diff --git a/regression-test/suites/nereids_p0/insert_into_table/partial_update.groovy b/regression-test/suites/nereids_p0/insert_into_table/partial_update.groovy index c734bcf1846..fd2145a71ed 100644 --- a/regression-test/suites/nereids_p0/insert_into_table/partial_update.groovy +++ b/regression-test/suites/nereids_p0/insert_into_table/partial_update.groovy @@ -56,7 +56,7 @@ suite("nereids_partial_update_native_insert_stmt", "p0") { qt_1 """ select * from ${tableName} order by id; """ test { sql """insert into ${tableName} values(2,400),(1,200),(4,400)""" - exception "You must explicitly specify the columns to be updated when updating partial columns using the INSERT statement." + exception "Column count doesn't match value count" } sql "set enable_unique_key_partial_update=false;" sql "sync;" diff --git a/regression-test/suites/nereids_p0/insert_into_table/partial_update_complex.groovy b/regression-test/suites/nereids_p0/insert_into_table/partial_update_complex.groovy index f9857e259d1..00e13176e47 100644 --- a/regression-test/suites/nereids_p0/insert_into_table/partial_update_complex.groovy +++ b/regression-test/suites/nereids_p0/insert_into_table/partial_update_complex.groovy @@ -91,7 +91,7 @@ suite("nereids_partial_update_native_insert_stmt_complex", "p0") { sql """insert into ${tbName1} select ${tbName2}.id, ${tbName2}.c1, ${tbName2}.c3 * 100 from ${tbName2} inner join ${tbName3} on ${tbName2}.id = ${tbName3}.id; """ - exception "You must explicitly specify the columns to be updated when updating partial columns using the INSERT statement." + exception "Column count doesn't match value count" } sql "truncate table ${tbName1};" sql "truncate table ${tbName2};" diff --git a/regression-test/suites/unique_with_mow_p0/partial_update/test_partial_update_native_insert_stmt.groovy b/regression-test/suites/unique_with_mow_p0/partial_update/test_partial_update_native_insert_stmt.groovy index bf128ba26b4..f3d32e2bc50 100644 --- a/regression-test/suites/unique_with_mow_p0/partial_update/test_partial_update_native_insert_stmt.groovy +++ b/regression-test/suites/unique_with_mow_p0/partial_update/test_partial_update_native_insert_stmt.groovy @@ -56,7 +56,7 @@ suite("test_partial_update_native_insert_stmt", "p0") { qt_1 """ select * from ${tableName} order by id; """ test { sql """insert into ${tableName} values(2,400),(1,200),(4,400)""" - exception "You must explicitly specify the columns to be updated when updating partial columns using the INSERT statement." + exception "Column count doesn't match value count" } sql "set enable_unique_key_partial_update=false;" sql "sync;" @@ -329,12 +329,10 @@ suite("test_partial_update_native_insert_stmt", "p0") { DISTRIBUTED BY HASH(`user_id`) BUCKETS 1 PROPERTIES ("replication_allocation" = "tag.location.default: 1", "enable_unique_key_merge_on_write" = "false");""" - test { - sql """insert into ${tableName10} values - (10000,"2017-10-01","2017-10-01 08:00:05","北京",20,0,"2017-10-01 06:00:00",20,10,10), - (10000,"2017-10-01","2017-10-01 09:00:05","北京",20,0,"2017-10-01 07:00:00",15,2,2); """ - exception "Partial update is only allowed on unique table with merge-on-write enabled" - } + sql """insert into ${tableName10} values + (10000,"2017-10-01","2017-10-01 08:00:05","北京",20,0,"2017-10-01 06:00:00",20,10,10), + (10000,"2017-10-01","2017-10-01 09:00:05","北京",20,0,"2017-10-01 07:00:00",15,2,2); """ + qt_sql "select * from ${tableName10} order by user_id;" sql """ DROP TABLE IF EXISTS ${tableName8}; """ sql """ DROP TABLE IF EXISTS ${tableName9}; """ diff --git a/regression-test/suites/unique_with_mow_p0/partial_update/test_partial_update_native_insert_stmt_complex.groovy b/regression-test/suites/unique_with_mow_p0/partial_update/test_partial_update_native_insert_stmt_complex.groovy index ad143a04be3..543a3fe698a 100644 --- a/regression-test/suites/unique_with_mow_p0/partial_update/test_partial_update_native_insert_stmt_complex.groovy +++ b/regression-test/suites/unique_with_mow_p0/partial_update/test_partial_update_native_insert_stmt_complex.groovy @@ -93,7 +93,7 @@ suite("test_partial_update_native_insert_stmt_complex", "p0") { sql """insert into ${tbName1} select ${tbName2}.id, ${tbName2}.c1, ${tbName2}.c3 * 100 from ${tbName2} inner join ${tbName3} on ${tbName2}.id = ${tbName3}.id; """ - exception "You must explicitly specify the columns to be updated when updating partial columns using the INSERT statement." + exception "Column count doesn't match value count" } sql "truncate table ${tbName1};" sql "truncate table ${tbName2};" --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org