This is an automated email from the ASF dual-hosted git repository.
zhangchen 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 f4d628f8703 [branch-2.0](cherry-pick) update error code when failed to
fill the missing fields (#29103) (#29220)
f4d628f8703 is described below
commit f4d628f870323bb2130ed05cef0e03d0bb4ea5c5
Author: zhannngchen <[email protected]>
AuthorDate: Thu Dec 28 17:17:09 2023 +0800
[branch-2.0](cherry-pick) update error code when failed to fill the missing
fields (#29103) (#29220)
cherry-pick #29103
---
be/src/olap/rowset/segment_v2/segment_writer.cpp | 15 ++++++++++++---
be/src/vec/sink/vtablet_sink.cpp | 18 ++++++++++--------
.../nereids_p0/insert_into_table/partial_update.groovy | 2 +-
.../test_partial_update_native_insert_stmt.groovy | 2 +-
4 files changed, 24 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 29ec7e02bc5..0453c5d7fd5 100644
--- a/be/src/olap/rowset/segment_v2/segment_writer.cpp
+++ b/be/src/olap/rowset/segment_v2/segment_writer.cpp
@@ -460,9 +460,18 @@ Status
SegmentWriter::append_block_with_partial_content(const vectorized::Block*
}
if
(!_opts.rowset_ctx->partial_update_info->can_insert_new_rows_in_partial_update)
{
- return Status::InternalError(
- "the unmentioned columns should have default value or
be nullable for "
- "newly inserted rows in non-strict mode 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);
}
has_default_or_nullable = true;
use_default_or_null_flag.emplace_back(true);
diff --git a/be/src/vec/sink/vtablet_sink.cpp b/be/src/vec/sink/vtablet_sink.cpp
index 281edeafe68..161a6572b9d 100644
--- a/be/src/vec/sink/vtablet_sink.cpp
+++ b/be/src/vec/sink/vtablet_sink.cpp
@@ -167,16 +167,16 @@ void IndexChannel::mark_as_failed(const VNodeChannel*
node_channel, const std::s
_failed_channels_msgs.emplace(the_tablet_id,
err + ", host: " +
node_channel->host());
if (_failed_channels[the_tablet_id].size() >=
least_tablet_success_channel_num) {
- _intolerable_failure_status =
-
Status::InternalError(_failed_channels_msgs[the_tablet_id]);
+ _intolerable_failure_status =
Status::Error<ErrorCode::INTERNAL_ERROR, false>(
+ _failed_channels_msgs[the_tablet_id]);
}
}
} else {
_failed_channels[tablet_id].insert(node_id);
_failed_channels_msgs.emplace(tablet_id, err + ", host: " +
node_channel->host());
if (_failed_channels[tablet_id].size() >=
least_tablet_success_channel_num) {
- _intolerable_failure_status =
-
Status::InternalError(_failed_channels_msgs[tablet_id]);
+ _intolerable_failure_status =
Status::Error<ErrorCode::INTERNAL_ERROR, false>(
+ _failed_channels_msgs[tablet_id]);
}
}
}
@@ -397,7 +397,7 @@ Status VNodeChannel::open_wait() {
delete _open_closure;
}
_open_closure = nullptr;
- return Status::InternalError(
+ return Status::Error<ErrorCode::INTERNAL_ERROR, false>(
"failed to open tablet writer, error={}, error_text={},
info={}",
berror(error_code), error_text, channel_info());
}
@@ -531,7 +531,8 @@ Status VNodeChannel::add_block(vectorized::Block* block,
const Payload* payload,
if (!st.ok()) {
if (_cancelled) {
std::lock_guard<doris::SpinLock> l(_cancel_msg_lock);
- return Status::InternalError("add row failed. {}", _cancel_msg);
+ return Status::Error<ErrorCode::INTERNAL_ERROR, false>("add row
failed. {}",
+
_cancel_msg);
} else {
return std::move(st.prepend("already stopped, can't add row.
cancelled/eos: "));
}
@@ -881,7 +882,8 @@ Status VNodeChannel::close_wait(RuntimeState* state) {
if (!st.ok()) {
if (_cancelled) {
std::lock_guard<doris::SpinLock> l(_cancel_msg_lock);
- return Status::InternalError("wait close failed. {}", _cancel_msg);
+ return Status::Error<ErrorCode::INTERNAL_ERROR, false>("wait close
failed. {}",
+
_cancel_msg);
} else {
return std::move(
st.prepend("already stopped, skip waiting for close.
cancelled/!eos: "));
@@ -908,7 +910,7 @@ Status VNodeChannel::close_wait(RuntimeState* state) {
return Status::OK();
}
- return Status::InternalError(get_cancel_msg());
+ return Status::Error<ErrorCode::INTERNAL_ERROR, false>(get_cancel_msg());
}
void VNodeChannel::_close_check() {
diff --git
a/regression-test/suites/nereids_p0/insert_into_table/partial_update.groovy
b/regression-test/suites/nereids_p0/insert_into_table/partial_update.groovy
index 5fcf4e63dee..da697fa20e6 100644
--- a/regression-test/suites/nereids_p0/insert_into_table/partial_update.groovy
+++ b/regression-test/suites/nereids_p0/insert_into_table/partial_update.groovy
@@ -122,7 +122,7 @@ suite("nereids_partial_update_native_insert_stmt", "p0") {
// but field `name` is not nullable and doesn't have default value
test {
sql """insert into ${tableName3}(id,score)
values(2,400),(1,200),(4,400)"""
- exception "INTERNAL_ERROR"
+ exception "the unmentioned column `name` should have default
value or be nullable"
}
sql "set enable_unique_key_partial_update=false;"
sql "sync;"
diff --git
a/regression-test/suites/unique_with_mow_p0/partial_update/test_partial_update_native_insert_stmt.groovy
b/regression-test/suites/unique_with_mow_p0/partial_update/test_partial_update_native_insert_stmt.groovy
index 7cd99165272..bf128ba26b4 100644
---
a/regression-test/suites/unique_with_mow_p0/partial_update/test_partial_update_native_insert_stmt.groovy
+++
b/regression-test/suites/unique_with_mow_p0/partial_update/test_partial_update_native_insert_stmt.groovy
@@ -122,7 +122,7 @@ suite("test_partial_update_native_insert_stmt", "p0") {
// but field `name` is not nullable and doesn't have default value
test {
sql """insert into ${tableName3}(id,score)
values(2,400),(1,200),(4,400)"""
- exception "INTERNAL_ERROR"
+ exception "the unmentioned column `name` should have default
value or be nullable"
}
sql "set enable_unique_key_partial_update=false;"
sql "sync;"
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]