[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
This commit is contained in:
@ -211,7 +211,7 @@ public class OriginalPlanner extends Planner {
|
||||
}
|
||||
checkAndSetTopnOpt(singleNodePlan);
|
||||
|
||||
if (queryOptions.num_nodes == 1 || queryStmt.isPointQuery()) {
|
||||
if ((queryOptions.num_nodes == 1 || queryStmt.isPointQuery()) && !(statement instanceof InsertStmt)) {
|
||||
// single-node execution; we're almost done
|
||||
singleNodePlan = addUnassignedConjuncts(analyzer, singleNodePlan);
|
||||
fragments.add(new PlanFragment(plannerContext.getNextFragmentId(), singleNodePlan,
|
||||
|
||||
@ -23,3 +23,18 @@ date_value DATE Yes false \N NONE
|
||||
2 20 2 2000.0 2000-01-02
|
||||
3 3 3 3.0 2000-01-03
|
||||
|
||||
-- !sql --
|
||||
a 1 2023-11-12T00:00 test1 1
|
||||
b 2 2023-11-12T00:00 test2 2
|
||||
c 3 2023-11-12T00:00 test3 3
|
||||
|
||||
-- !sql --
|
||||
a 1 2023-11-12T00:00 test1 999
|
||||
b 2 2023-11-12T00:00 test2 2
|
||||
c 3 2023-11-12T00:00 test3 3
|
||||
|
||||
-- !sql --
|
||||
a 1 2023-11-12T00:00 test1 999
|
||||
b 2 2023-11-12T00:00 test2 2
|
||||
c 3 2022-01-01T00:00 update value 3
|
||||
|
||||
|
||||
@ -96,4 +96,35 @@ suite("test_update_mow", "p0") {
|
||||
sql "DROP TABLE IF EXISTS ${tbName2}"
|
||||
sql "DROP TABLE IF EXISTS ${tbName3}"
|
||||
sql "DROP TABLE IF EXISTS ${tbName4}"
|
||||
|
||||
|
||||
sql "set experimental_enable_nereids_planner=false;"
|
||||
sql "set enable_nereids_planner=false"
|
||||
sql "sync"
|
||||
def tableName5 = "test_update_mow_5"
|
||||
sql "DROP TABLE IF EXISTS ${tableName5}"
|
||||
sql """ CREATE TABLE ${tableName5} (
|
||||
k1 varchar(100) NOT NULL,
|
||||
k2 int(11) NOT NULL,
|
||||
v1 datetime NULL,
|
||||
v2 varchar(100) NULL,
|
||||
v3 int NULL) ENGINE=OLAP UNIQUE KEY(k1, k2) COMMENT 'OLAP'
|
||||
DISTRIBUTED BY HASH(k1, k2) BUCKETS 3
|
||||
PROPERTIES (
|
||||
"replication_allocation" = "tag.location.default: 1",
|
||||
"enable_unique_key_merge_on_write" = "true",
|
||||
"light_schema_change" = "true",
|
||||
"store_row_column" = "true",
|
||||
"enable_single_replica_compaction" = "false");"""
|
||||
sql """insert into ${tableName5} values
|
||||
("a",1,"2023-11-12 00:00:00","test1",1),
|
||||
("b",2,"2023-11-12 00:00:00","test2",2),
|
||||
("c",3,"2023-11-12 00:00:00","test3",3);"""
|
||||
qt_sql "select * from ${tableName5} order by k1,k2"
|
||||
sql """update ${tableName5} set v3=999 where k1="a" and k2=1;"""
|
||||
qt_sql "select * from ${tableName5} order by k1,k2"
|
||||
sql """update ${tableName5} set v2="update value", v1="2022-01-01 00:00:00" where k1="c" and k2=3;"""
|
||||
qt_sql "select * from ${tableName5} order by k1,k2"
|
||||
|
||||
sql "DROP TABLE IF EXISTS ${tableName5}"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user