You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by kx...@apache.org on 2023/11/20 10:01:21 UTC

(doris) branch branch-2.0 updated: [fix](partial update) keep case insensitivity and use the columns' origin names in partialUpdateCols in origin planner #27223 (#27255)

This is an automated email from the ASF dual-hosted git repository.

kxiao pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
     new 2c4e3f04b29 [fix](partial update) keep case insensitivity and use the columns' origin names in partialUpdateCols in origin planner #27223 (#27255)
2c4e3f04b29 is described below

commit 2c4e3f04b2975816a916e1c14949de70906858d0
Author: bobhan1 <bh...@outlook.com>
AuthorDate: Mon Nov 20 18:01:09 2023 +0800

    [fix](partial update) keep case insensitivity and use the columns' origin names in partialUpdateCols in origin planner #27223 (#27255)
---
 .../apache/doris/analysis/NativeInsertStmt.java    |  8 ++-
 .../test_partial_update_case_insensitivity.out     | 77 ++++++++++++++++++++++
 .../test_partial_update_case_insensitivity.groovy  | 71 ++++++++++++++++++++
 3 files changed, 154 insertions(+), 2 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 0105ae48fc8..cc2d1341377 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
@@ -1012,7 +1012,7 @@ public class NativeInsertStmt extends InsertStmt {
         for (Column col : olapTable.getFullSchema()) {
             boolean exists = false;
             for (Column insertCol : targetColumns) {
-                if (insertCol.getName() != null && insertCol.getName().equals(col.getName())) {
+                if (insertCol.getName() != null && insertCol.getName().equalsIgnoreCase(col.getName())) {
                     if (!col.isVisible() && !Column.DELETE_SIGN.equals(col.getName())) {
                         throw new UserException("Partial update should not include invisible column except"
                                     + " delete sign column: " + col.getName());
@@ -1027,7 +1027,11 @@ public class NativeInsertStmt extends InsertStmt {
         }
 
         isPartialUpdate = true;
-        partialUpdateCols.addAll(targetColumnNames);
+        for (String name : targetColumnNames) {
+            Column column = olapTable.getFullSchema().stream()
+                    .filter(col -> col.getName().equalsIgnoreCase(name)).findFirst().get();
+            partialUpdateCols.add(column.getName());
+        }
         if (isPartialUpdate && olapTable.hasSequenceCol() && olapTable.getSequenceMapCol() != null
                 && partialUpdateCols.contains(olapTable.getSequenceMapCol())) {
             partialUpdateCols.add(Column.SEQUENCE_COL);
diff --git a/regression-test/data/unique_with_mow_p0/partial_update/test_partial_update_case_insensitivity.out b/regression-test/data/unique_with_mow_p0/partial_update/test_partial_update_case_insensitivity.out
new file mode 100644
index 00000000000..fd4ae128928
--- /dev/null
+++ b/regression-test/data/unique_with_mow_p0/partial_update/test_partial_update_case_insensitivity.out
@@ -0,0 +1,77 @@
+-- This file is automatically generated. You should know what you did if you want to edit this
+-- !sql --
+t1	1	\N	\N
+
+-- !sql --
+t1	1	2	\N
+
+-- !sql --
+t1	1	2	\N
+t2	\N	20	30
+
+-- !sql --
+t1	999	2	888
+t2	\N	20	30
+
+-- !sql --
+t1	999	2	888
+t2	\N	20	30
+t3	123	456	789
+
+-- !sql --
+t1	1	\N	\N
+
+-- !sql --
+t1	1	2	\N
+
+-- !sql --
+t1	1	2	\N
+t2	\N	20	30
+
+-- !sql --
+t1	999	2	888
+t2	\N	20	30
+
+-- !sql --
+t1	999	2	888
+t2	\N	20	30
+t3	123	456	789
+
+-- !sql --
+t1	1	\N	\N
+
+-- !sql --
+t1	1	2	\N
+
+-- !sql --
+t1	1	2	\N
+t2	\N	20	30
+
+-- !sql --
+t1	999	2	888
+t2	\N	20	30
+
+-- !sql --
+t1	999	2	888
+t2	\N	20	30
+t3	123	456	789
+
+-- !sql --
+t1	1	\N	\N
+
+-- !sql --
+t1	1	2	\N
+
+-- !sql --
+t1	1	2	\N
+t2	\N	20	30
+
+-- !sql --
+t1	999	2	888
+t2	\N	20	30
+
+-- !sql --
+t1	999	2	888
+t2	\N	20	30
+t3	123	456	789
+
diff --git a/regression-test/suites/unique_with_mow_p0/partial_update/test_partial_update_case_insensitivity.groovy b/regression-test/suites/unique_with_mow_p0/partial_update/test_partial_update_case_insensitivity.groovy
new file mode 100644
index 00000000000..c1828343f07
--- /dev/null
+++ b/regression-test/suites/unique_with_mow_p0/partial_update/test_partial_update_case_insensitivity.groovy
@@ -0,0 +1,71 @@
+
+// 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_case_insensitivity", "p0") {
+    String db = context.config.getDbNameByFile(context.file)
+    sql "select 1;" // to create database
+
+    for (def use_row_store : [false, true]) {
+        for (def use_nereids_planner : [false, true]) {
+            logger.info("current params: use_row_store: ${use_row_store}, use_nereids_planner: ${use_nereids_planner}")
+            connect(user = context.config.jdbcUser, password = context.config.jdbcPassword, url = context.config.jdbcUrl) {
+                sql "use ${db};"
+                if (use_nereids_planner) {
+                    sql """ set enable_nereids_dml = true; """
+                    sql """ set enable_nereids_planner=true; """
+                    sql """ set enable_fallback_to_original_planner=false; """
+                } else {
+                    sql """ set enable_nereids_dml = false; """
+                    sql """ set enable_nereids_planner = false; """
+                }
+
+                def tableName = "test_partial_update_case_insensitivity"
+                sql """ DROP TABLE IF EXISTS ${tableName} """
+                sql """ CREATE TABLE ${tableName} (
+                        name varchar(300),
+                        status int,
+                        MY_COLUMN int,
+                        UpAndDown int
+                        ) ENGINE=OLAP
+                        UNIQUE KEY(name) COMMENT 'OLAP'
+                        DISTRIBUTED BY HASH(name) BUCKETS 1
+                        PROPERTIES (
+                        "replication_allocation" = "tag.location.default: 1",
+                        "enable_unique_key_merge_on_write" = "true",
+                        "store_row_column" = "${use_row_store}");"""
+                
+                sql "set enable_unique_key_partial_update = true;"
+                sql "set enable_insert_strict = false;"
+                sql "sync;"
+
+                sql """ insert into ${tableName}(name, STATUS) values("t1", 1); """
+                qt_sql "select * from ${tableName} order by name;"
+                sql """ insert into ${tableName}(name, my_column) values("t1", 2); """
+                qt_sql "select * from ${tableName} order by name;"
+                sql """ insert into ${tableName}(name, My_Column, uPaNddOWN) values("t2", 20, 30); """
+                qt_sql "select * from ${tableName} order by name;"
+                sql """ insert into ${tableName}(NAME, StAtUs, upanddown) values("t1", 999, 888); """
+                qt_sql "select * from ${tableName} order by name;"
+                sql """ insert into ${tableName}(NaMe, StAtUs, mY_CoLUmN, upAndDoWn) values("t3", 123, 456, 789); """
+                qt_sql "select * from ${tableName} order by name;"
+
+                sql """ DROP TABLE IF EXISTS ${tableName} """
+            }
+        }
+    }
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org