forked from apache/doris
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Problem: As shown in the issue above, if a key deleted by a delete statement is written to by updating only certain columns, the data will not display correctly. Reason: The delete statement deletes the data by writing a delete predicate, which is stored in the rowset meta and applied during data retrieval to filter the data. However, partial column updates do not consider the effect of the delete predicate when reading the original data. The imported key should be considered as a new key (since it has already been deleted), but it is actually treated as an old key. Therefore, only some columns are updated, leading to incorrect results. Solution: Consider the delete predicate during partial column updates, but this method will result in reading more columns, as shown in apache#35766. Thus, in this PR, we change the delete operation in the mow table from writing a delete predicate to writing a delete sign, which effectively resolves the issue.
- Loading branch information
1 parent
4fe2648
commit 81cb381
Showing
14 changed files
with
139 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,10 +32,12 @@ | |
2 2 | ||
2 20 | ||
2 200 | ||
3 0 | ||
3 100 | ||
3 300 | ||
|
||
-- !select_final -- | ||
1 100 | ||
2 200 | ||
3 0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,10 +32,12 @@ | |
2 2 | ||
2 20 | ||
2 200 | ||
3 0 | ||
3 100 | ||
3 300 | ||
|
||
-- !select_final -- | ||
1 100 | ||
2 200 | ||
3 0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,10 +96,10 @@ zzz | |
asd | ||
|
||
-- !select_16 -- | ||
qdf | ||
qwe | ||
|
||
-- !select_17 -- | ||
ll | ||
cc | ||
|
||
-- !select_18 -- | ||
zzz | ||
|
13 changes: 13 additions & 0 deletions
13
regression-test/data/unique_with_mow_p0/partial_update/test_partial_update_after_delete.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
-- This file is automatically generated. You should know what you did if you want to edit this | ||
-- !select1 -- | ||
1 2 \N | ||
|
||
-- !select2 -- | ||
1 2 \N | ||
|
||
-- !select1 -- | ||
1 2 \N | ||
|
||
-- !select2 -- | ||
1 2 \N | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
...ion-test/suites/unique_with_mow_p0/partial_update/test_partial_update_after_delete.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// 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_after_delete", "p0") { | ||
|
||
String db = context.config.getDbNameByFile(context.file) | ||
sql "select 1;" // to create database | ||
|
||
for (def use_row_store : [false, true]) { | ||
logger.info("current params: use_row_store: ${use_row_store}") | ||
|
||
connect(user = context.config.jdbcUser, password = context.config.jdbcPassword, url = context.config.jdbcUrl) { | ||
sql "use ${db};" | ||
sql "SET enable_nereids_planner=true;" | ||
sql "SET enable_fallback_to_original_planner=false;" | ||
sql "set enable_unique_key_partial_update=false;" | ||
sql "set enable_insert_strict=true;" | ||
def tableName1 = "test_partial_update_after_delete1" | ||
sql "DROP TABLE IF EXISTS ${tableName1};" | ||
sql """ CREATE TABLE IF NOT EXISTS ${tableName1} ( | ||
`k1` INT NULL, | ||
`v1` INT NULL, | ||
`v2` INT NULL | ||
)UNIQUE KEY(k1) | ||
DISTRIBUTED BY HASH(k1) BUCKETS 1 | ||
PROPERTIES ( | ||
"enable_unique_key_merge_on_write" = "true", | ||
"disable_auto_compaction" = "true", | ||
"replication_num" = "1", | ||
"store_row_column" = "${use_row_store}"); """ | ||
|
||
sql "insert into ${tableName1} values(1,1,1);" | ||
sql "delete from ${tableName1} where k1=1;" | ||
sql "set enable_unique_key_partial_update=true;" | ||
sql "set enable_insert_strict=false;" | ||
sql "insert into ${tableName1}(k1, v1) values(1,2);" | ||
qt_select1 "select * from ${tableName1};" | ||
|
||
sql "set enable_unique_key_partial_update=false;" | ||
sql "set enable_insert_strict=true;" | ||
sql "SET enable_nereids_planner=false;" | ||
sql "SET enable_fallback_to_original_planner=false;" | ||
def tableName2 = "test_partial_update_after_delete2" | ||
sql "DROP TABLE IF EXISTS ${tableName2};" | ||
sql """ CREATE TABLE IF NOT EXISTS ${tableName2} ( | ||
`k1` INT NULL, | ||
`v1` INT NULL, | ||
`v2` INT NULL | ||
)UNIQUE KEY(k1) | ||
DISTRIBUTED BY HASH(k1) BUCKETS 1 | ||
PROPERTIES ( | ||
"enable_unique_key_merge_on_write" = "true", | ||
"disable_auto_compaction" = "true", | ||
"replication_num" = "1", | ||
"store_row_column" = "${use_row_store}"); """ | ||
|
||
sql "insert into ${tableName2} values(1,1,1);" | ||
sql "delete from ${tableName2} where k1=1;" | ||
sql "set enable_unique_key_partial_update=true;" | ||
sql "set enable_insert_strict=false;" | ||
sql "insert into ${tableName2}(k1, v1) values(1,2);" | ||
qt_select2 "select * from ${tableName2};" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters