Skip to content

Commit 2853efd

Browse files
authored
[fix](partial update) Fix NPE when the query statement of an update statement is a point query in OriginPlanner (#26881)
close #26882 We should not use the singleNodePlan to generate the rootPlanFragment if the query is inside a insert statement or distributedPlanner will be null. introduced in #15491
1 parent 9bb46f4 commit 2853efd

3 files changed

Lines changed: 47 additions & 1 deletion

File tree

‎fe/fe-core/src/main/java/org/apache/doris/planner/OriginalPlanner.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ public void createPlanFragments(StatementBase statement, Analyzer analyzer, TQue
211211
}
212212
checkAndSetTopnOpt(singleNodePlan);
213213

214-
if (queryOptions.num_nodes == 1 || queryStmt.isPointQuery()) {
214+
if ((queryOptions.num_nodes == 1 || queryStmt.isPointQuery()) && !(statement instanceof InsertStmt)) {
215215
// single-node execution; we're almost done
216216
singleNodePlan = addUnassignedConjuncts(analyzer, singleNodePlan);
217217
fragments.add(new PlanFragment(plannerContext.getNextFragmentId(), singleNodePlan,

‎regression-test/data/update/test_update_mow.out‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,18 @@ date_value DATE Yes false \N NONE
2323
2 20 2 2000.0 2000-01-02
2424
3 3 3 3.0 2000-01-03
2525

26+
-- !sql --
27+
a 1 2023-11-12T00:00 test1 1
28+
b 2 2023-11-12T00:00 test2 2
29+
c 3 2023-11-12T00:00 test3 3
30+
31+
-- !sql --
32+
a 1 2023-11-12T00:00 test1 999
33+
b 2 2023-11-12T00:00 test2 2
34+
c 3 2023-11-12T00:00 test3 3
35+
36+
-- !sql --
37+
a 1 2023-11-12T00:00 test1 999
38+
b 2 2023-11-12T00:00 test2 2
39+
c 3 2022-01-01T00:00 update value 3
40+

‎regression-test/suites/update/test_update_mow.groovy‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,35 @@ suite("test_update_mow", "p0") {
9696
sql "DROP TABLE IF EXISTS ${tbName2}"
9797
sql "DROP TABLE IF EXISTS ${tbName3}"
9898
sql "DROP TABLE IF EXISTS ${tbName4}"
99+
100+
101+
sql "set experimental_enable_nereids_planner=false;"
102+
sql "set enable_nereids_planner=false"
103+
sql "sync"
104+
def tableName5 = "test_update_mow_5"
105+
sql "DROP TABLE IF EXISTS ${tableName5}"
106+
sql """ CREATE TABLE ${tableName5} (
107+
k1 varchar(100) NOT NULL,
108+
k2 int(11) NOT NULL,
109+
v1 datetime NULL,
110+
v2 varchar(100) NULL,
111+
v3 int NULL) ENGINE=OLAP UNIQUE KEY(k1, k2) COMMENT 'OLAP'
112+
DISTRIBUTED BY HASH(k1, k2) BUCKETS 3
113+
PROPERTIES (
114+
"replication_allocation" = "tag.location.default: 1",
115+
"enable_unique_key_merge_on_write" = "true",
116+
"light_schema_change" = "true",
117+
"store_row_column" = "true",
118+
"enable_single_replica_compaction" = "false");"""
119+
sql """insert into ${tableName5} values
120+
("a",1,"2023-11-12 00:00:00","test1",1),
121+
("b",2,"2023-11-12 00:00:00","test2",2),
122+
("c",3,"2023-11-12 00:00:00","test3",3);"""
123+
qt_sql "select * from ${tableName5} order by k1,k2"
124+
sql """update ${tableName5} set v3=999 where k1="a" and k2=1;"""
125+
qt_sql "select * from ${tableName5} order by k1,k2"
126+
sql """update ${tableName5} set v2="update value", v1="2022-01-01 00:00:00" where k1="c" and k2=3;"""
127+
qt_sql "select * from ${tableName5} order by k1,k2"
128+
129+
sql "DROP TABLE IF EXISTS ${tableName5}"
99130
}

0 commit comments

Comments
 (0)