This is an automated email from the ASF dual-hosted git repository.
kxiao pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new 89c8b3a4beb [fix](partial update) Fix error message when doing strict
mode partial update on a table with column that is non-nullable and has no
default value #29218 (#29225)
89c8b3a4beb is described below
commit 89c8b3a4bebec8b9cd06733028334ebc293451d7
Author: bobhan1 <[email protected]>
AuthorDate: Fri Dec 29 12:33:46 2023 +0800
[fix](partial update) Fix error message when doing strict mode partial
update on a table with column that is non-nullable and has no default value
#29218 (#29225)
---
be/src/olap/rowset/segment_v2/segment_writer.cpp | 27 +++++++--------
.../test_partial_update_strict_mode.out | 16 +++++++++
.../test_partial_update_strict_mode.groovy | 39 ++++++++++++++++++++++
3 files changed, 69 insertions(+), 13 deletions(-)
diff --git a/be/src/olap/rowset/segment_v2/segment_writer.cpp
b/be/src/olap/rowset/segment_v2/segment_writer.cpp
index 0453c5d7fd5..a777e358fc3 100644
--- a/be/src/olap/rowset/segment_v2/segment_writer.cpp
+++ b/be/src/olap/rowset/segment_v2/segment_writer.cpp
@@ -457,21 +457,22 @@ Status
SegmentWriter::append_block_with_partial_content(const vectorized::Block*
_mow_context->delete_bitmap->add({_opts.rowset_ctx->rowset_id,
_segment_id,
DeleteBitmap::TEMP_VERSION_COMMON},
segment_pos);
- }
-
- if
(!_opts.rowset_ctx->partial_update_info->can_insert_new_rows_in_partial_update)
{
- std::string error_column;
- for (auto cid :
_opts.rowset_ctx->partial_update_info->missing_cids) {
- const TabletColumn& col = _tablet_schema->column(cid);
- if (!col.has_default_value() && !col.is_nullable()) {
- error_column = col.name();
- break;
+ } else {
+ if
(!_opts.rowset_ctx->partial_update_info->can_insert_new_rows_in_partial_update)
{
+ std::string error_column;
+ for (auto cid :
_opts.rowset_ctx->partial_update_info->missing_cids) {
+ const TabletColumn& col = _tablet_schema->column(cid);
+ if (!col.has_default_value() && !col.is_nullable()) {
+ error_column = col.name();
+ break;
+ }
}
+ return Status::Error<INVALID_SCHEMA, false>(
+ "the unmentioned column `{}` should have default
value or be nullable "
+ "for "
+ "newly inserted rows in non-strict mode partial
update",
+ error_column);
}
- return Status::Error<INVALID_SCHEMA, false>(
- "the unmentioned column `{}` should have default value
or be nullable for "
- "newly inserted rows in non-strict mode partial
update",
- error_column);
}
has_default_or_nullable = true;
use_default_or_null_flag.emplace_back(true);
diff --git
a/regression-test/data/unique_with_mow_p0/partial_update/test_partial_update_strict_mode.out
b/regression-test/data/unique_with_mow_p0/partial_update/test_partial_update_strict_mode.out
index aa1946a5e41..93fa33d81f9 100644
---
a/regression-test/data/unique_with_mow_p0/partial_update/test_partial_update_strict_mode.out
+++
b/regression-test/data/unique_with_mow_p0/partial_update/test_partial_update_strict_mode.out
@@ -25,6 +25,14 @@
1 kevin 18 shenzhen 400 2023-07-01T12:00
3 steve 23 beijing 500 2023-07-03T12:00:02
+-- !sql --
+1 kevin 18 shenzhen 400 2023-07-01T12:00
+3 steve 23 beijing 500 2023-07-03T12:00:02
+
+-- !sql --
+1 kevin 18 shenzhen 400 2023-07-01T12:00
+3 steve 23 beijing 500 2023-07-03T12:00:02
+
-- !sql --
1 kevin 18 shenzhen 400 2023-07-01T12:00
@@ -51,3 +59,11 @@
1 kevin 18 shenzhen 400 2023-07-01T12:00
3 steve 23 beijing 500 2023-07-03T12:00:02
+-- !sql --
+1 kevin 18 shenzhen 400 2023-07-01T12:00
+3 steve 23 beijing 500 2023-07-03T12:00:02
+
+-- !sql --
+1 kevin 18 shenzhen 400 2023-07-01T12:00
+3 steve 23 beijing 500 2023-07-03T12:00:02
+
diff --git
a/regression-test/suites/unique_with_mow_p0/partial_update/test_partial_update_strict_mode.groovy
b/regression-test/suites/unique_with_mow_p0/partial_update/test_partial_update_strict_mode.groovy
index 726e04c684e..54e4937bfef 100644
---
a/regression-test/suites/unique_with_mow_p0/partial_update/test_partial_update_strict_mode.groovy
+++
b/regression-test/suites/unique_with_mow_p0/partial_update/test_partial_update_strict_mode.groovy
@@ -219,6 +219,45 @@ suite("test_partial_update_strict_mode", "p0") {
sql "sync"
qt_sql """select * from ${tableName4} order by id;"""
sql """ DROP TABLE IF EXISTS ${tableName4}; """
+
+
+ // column `city` is non-nullable and has no default value
+ def tableName5 = "test_partial_update_strict_mode5"
+ sql """ DROP TABLE IF EXISTS ${tableName5} """
+ sql """
+ CREATE TABLE ${tableName5} (
+ `id` int(11) NULL,
+ `name` varchar(10) NULL,
+ `age` int(11) NULL DEFAULT "20",
+ `city` varchar(10) NOT NULL,
+ `balance` decimalv3(9, 0) NULL,
+ `last_access_time` datetime NULL
+ ) ENGINE = OLAP UNIQUE KEY(`id`)
+ COMMENT 'OLAP' DISTRIBUTED BY HASH(`id`)
+ BUCKETS 4 PROPERTIES (
+ "replication_allocation" = "tag.location.default: 1",
+ "storage_format" = "V2",
+ "enable_unique_key_merge_on_write" = "true",
+ "light_schema_change" = "true",
+ "disable_auto_compaction" = "false",
+ "enable_single_replica_compaction" = "false",
+ "store_row_column" = "${use_row_store}"); """
+ sql """insert into ${tableName5}
values(1,"kevin",18,"shenzhen",400,"2023-07-01 12:00:00");"""
+ sql """insert into ${tableName5}
values(3,"steve",23,"beijing",500,"2023-07-03 12:00:02");"""
+ sql "sync;"
+ qt_sql """select * from ${tableName5} order by id;"""
+ sql "set enable_unique_key_partial_update=true;"
+ sql "set enable_insert_strict=true;"
+ sql "sync"
+ test {
+ sql """insert into ${tableName5}(id,balance,last_access_time)
values
+ (1,600,"2023-08-03 12:00:01"),
+ (2,500,"2023-07-03 12:00:01"),
+ (4,23,"2023-07-03 12:00:02");"""
+ exception "Insert has filtered data in strict mode"
+ }
+ sql "sync;"
+ qt_sql """select * from ${tableName5} order by id;"""
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]