Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix](partial update) Fix NPE when the query statement of an update statement is a point query in OriginPlanner #26881

Merged
merged 3 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public void createPlanFragments(StatementBase statement, Analyzer analyzer, TQue
}
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,
Expand Down
15 changes: 15 additions & 0 deletions regression-test/data/update/test_update_mow.out
Original file line number Diff line number Diff line change
Expand Up @@ -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

31 changes: 31 additions & 0 deletions regression-test/suites/update/test_update_mow.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
}
Loading