Skip to content

Commit 7c38883

Browse files
bobhan1seawinde
authored andcommitted
[fix](partial update) keep case insensitivity and use the columns' origin names in partialUpdateCols in origin planner (apache#27223)
close: apache#27161
1 parent 048c7ef commit 7c38883

3 files changed

Lines changed: 154 additions & 2 deletions

File tree

‎fe/fe-core/src/main/java/org/apache/doris/analysis/NativeInsertStmt.java‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,7 +1156,7 @@ private void trySetPartialUpdate() throws UserException {
11561156
for (Column col : olapTable.getFullSchema()) {
11571157
boolean exists = false;
11581158
for (Column insertCol : targetColumns) {
1159-
if (insertCol.getName() != null && insertCol.getName().equals(col.getName())) {
1159+
if (insertCol.getName() != null && insertCol.getName().equalsIgnoreCase(col.getName())) {
11601160
if (!col.isVisible() && !Column.DELETE_SIGN.equals(col.getName())) {
11611161
throw new UserException("Partial update should not include invisible column except"
11621162
+ " delete sign column: " + col.getName());
@@ -1171,7 +1171,11 @@ private void trySetPartialUpdate() throws UserException {
11711171
}
11721172

11731173
isPartialUpdate = true;
1174-
partialUpdateCols.addAll(targetColumnNames);
1174+
for (String name : targetColumnNames) {
1175+
Column column = olapTable.getFullSchema().stream()
1176+
.filter(col -> col.getName().equalsIgnoreCase(name)).findFirst().get();
1177+
partialUpdateCols.add(column.getName());
1178+
}
11751179
if (isPartialUpdate && olapTable.hasSequenceCol() && olapTable.getSequenceMapCol() != null
11761180
&& partialUpdateCols.contains(olapTable.getSequenceMapCol())) {
11771181
partialUpdateCols.add(Column.SEQUENCE_COL);
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
-- This file is automatically generated. You should know what you did if you want to edit this
2+
-- !sql --
3+
t1 1 \N \N
4+
5+
-- !sql --
6+
t1 1 2 \N
7+
8+
-- !sql --
9+
t1 1 2 \N
10+
t2 \N 20 30
11+
12+
-- !sql --
13+
t1 999 2 888
14+
t2 \N 20 30
15+
16+
-- !sql --
17+
t1 999 2 888
18+
t2 \N 20 30
19+
t3 123 456 789
20+
21+
-- !sql --
22+
t1 1 \N \N
23+
24+
-- !sql --
25+
t1 1 2 \N
26+
27+
-- !sql --
28+
t1 1 2 \N
29+
t2 \N 20 30
30+
31+
-- !sql --
32+
t1 999 2 888
33+
t2 \N 20 30
34+
35+
-- !sql --
36+
t1 999 2 888
37+
t2 \N 20 30
38+
t3 123 456 789
39+
40+
-- !sql --
41+
t1 1 \N \N
42+
43+
-- !sql --
44+
t1 1 2 \N
45+
46+
-- !sql --
47+
t1 1 2 \N
48+
t2 \N 20 30
49+
50+
-- !sql --
51+
t1 999 2 888
52+
t2 \N 20 30
53+
54+
-- !sql --
55+
t1 999 2 888
56+
t2 \N 20 30
57+
t3 123 456 789
58+
59+
-- !sql --
60+
t1 1 \N \N
61+
62+
-- !sql --
63+
t1 1 2 \N
64+
65+
-- !sql --
66+
t1 1 2 \N
67+
t2 \N 20 30
68+
69+
-- !sql --
70+
t1 999 2 888
71+
t2 \N 20 30
72+
73+
-- !sql --
74+
t1 999 2 888
75+
t2 \N 20 30
76+
t3 123 456 789
77+
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
2+
// Licensed to the Apache Software Foundation (ASF) under one
3+
// or more contributor license agreements. See the NOTICE file
4+
// distributed with this work for additional information
5+
// regarding copyright ownership. The ASF licenses this file
6+
// to you under the Apache License, Version 2.0 (the
7+
// "License"); you may not use this file except in compliance
8+
// with the License. You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing,
13+
// software distributed under the License is distributed on an
14+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
// KIND, either express or implied. See the License for the
16+
// specific language governing permissions and limitations
17+
// under the License.
18+
19+
suite("test_partial_update_case_insensitivity", "p0") {
20+
String db = context.config.getDbNameByFile(context.file)
21+
sql "select 1;" // to create database
22+
23+
for (def use_row_store : [false, true]) {
24+
for (def use_nereids_planner : [false, true]) {
25+
logger.info("current params: use_row_store: ${use_row_store}, use_nereids_planner: ${use_nereids_planner}")
26+
connect(user = context.config.jdbcUser, password = context.config.jdbcPassword, url = context.config.jdbcUrl) {
27+
sql "use ${db};"
28+
if (use_nereids_planner) {
29+
sql """ set enable_nereids_dml = true; """
30+
sql """ set enable_nereids_planner=true; """
31+
sql """ set enable_fallback_to_original_planner=false; """
32+
} else {
33+
sql """ set enable_nereids_dml = false; """
34+
sql """ set enable_nereids_planner = false; """
35+
}
36+
37+
def tableName = "test_partial_update_case_insensitivity"
38+
sql """ DROP TABLE IF EXISTS ${tableName} """
39+
sql """ CREATE TABLE ${tableName} (
40+
name varchar(300),
41+
status int,
42+
MY_COLUMN int,
43+
UpAndDown int
44+
) ENGINE=OLAP
45+
UNIQUE KEY(name) COMMENT 'OLAP'
46+
DISTRIBUTED BY HASH(name) BUCKETS 1
47+
PROPERTIES (
48+
"replication_allocation" = "tag.location.default: 1",
49+
"enable_unique_key_merge_on_write" = "true",
50+
"store_row_column" = "${use_row_store}");"""
51+
52+
sql "set enable_unique_key_partial_update = true;"
53+
sql "set enable_insert_strict = false;"
54+
sql "sync;"
55+
56+
sql """ insert into ${tableName}(name, STATUS) values("t1", 1); """
57+
qt_sql "select * from ${tableName} order by name;"
58+
sql """ insert into ${tableName}(name, my_column) values("t1", 2); """
59+
qt_sql "select * from ${tableName} order by name;"
60+
sql """ insert into ${tableName}(name, My_Column, uPaNddOWN) values("t2", 20, 30); """
61+
qt_sql "select * from ${tableName} order by name;"
62+
sql """ insert into ${tableName}(NAME, StAtUs, upanddown) values("t1", 999, 888); """
63+
qt_sql "select * from ${tableName} order by name;"
64+
sql """ insert into ${tableName}(NaMe, StAtUs, mY_CoLUmN, upAndDoWn) values("t3", 123, 456, 789); """
65+
qt_sql "select * from ${tableName} order by name;"
66+
67+
sql """ DROP TABLE IF EXISTS ${tableName} """
68+
}
69+
}
70+
}
71+
}

0 commit comments

Comments
 (0)