[fix](partial update) keep case insensitivity and use the columns' origin names in partialUpdateCols in origin planner (#27223)

close: #27161
This commit is contained in:
bobhan1
2023-11-20 21:16:28 +08:00
committed by GitHub
parent fec94b7278
commit 0b459e50fb
3 changed files with 154 additions and 2 deletions

View File

@ -1156,7 +1156,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());
@ -1171,7 +1171,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);

View File

@ -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

View File

@ -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} """
}
}
}
}