diff --git a/be/src/common/status.h b/be/src/common/status.h index 0fa6257bd00186..09a22311af9b8e 100644 --- a/be/src/common/status.h +++ b/be/src/common/status.h @@ -563,7 +563,7 @@ inline std::string Status::to_string() const { } inline std::string Status::to_string_no_stack() const { - return fmt::format("[{}] {}", code_as_string(), msg()); + return fmt::format("[{}]{}", code_as_string(), msg()); } // some generally useful macros diff --git a/be/src/vec/sink/vtablet_finder.cpp b/be/src/vec/sink/vtablet_finder.cpp index 2e0d278fa4fe01..3bfd5bb4d22e96 100644 --- a/be/src/vec/sink/vtablet_finder.cpp +++ b/be/src/vec/sink/vtablet_finder.cpp @@ -62,7 +62,7 @@ Status OlapTabletFinder::find_tablets(RuntimeState* state, Block* block, int row _num_filtered_rows++; _filter_bitmap.Set(row_index, true); if (stop_processing) { - return Status::EndOfFile("Encountered unqualified data, stop processing"); + return Status::DataQualityError("Encountered unqualified data, stop processing"); } skip[row_index] = true; continue; @@ -104,4 +104,4 @@ Status OlapTabletFinder::find_tablets(RuntimeState* state, Block* block, int row return Status::OK(); } -} // namespace doris::vectorized \ No newline at end of file +} // namespace doris::vectorized diff --git a/regression-test/suites/insert_p0/test_insert_partition_fail_url.groovy b/regression-test/suites/insert_p0/test_insert_partition_fail_url.groovy new file mode 100644 index 00000000000000..9b0a7f3a1a7782 --- /dev/null +++ b/regression-test/suites/insert_p0/test_insert_partition_fail_url.groovy @@ -0,0 +1,91 @@ +// 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. + +import com.mysql.cj.jdbc.StatementImpl + +suite("test_insert_partition_fail_url") { + def dbName = "regression_test_insert_p0" + def srcTableName = "test_insert_partition_fail_url_src" + def dstTableName = "test_insert_partition_fail_url_dst" + def srcName = dbName + "." + srcTableName + def dstName = dbName + "." + dstTableName + + // create table + sql """ drop table if exists ${srcName}; """ + sql """ + CREATE TABLE ${srcName} ( + `id` int NOT NULL, + `score` int NULL default "-1" + ) ENGINE=OLAP + DUPLICATE KEY(`id`) + DISTRIBUTED BY HASH(`id`) BUCKETS 1 + PROPERTIES ( + "replication_num" = "1" + ); + """ + + sql """ drop table if exists ${dstName}; """ + sql """ + CREATE TABLE ${dstName} ( + `id` int NOT NULL, + `score` int NULL default "-1" + ) ENGINE=OLAP + DUPLICATE KEY(`id`) + PARTITION BY RANGE(`id`) + ( + PARTITION `p0` VALUES LESS THAN ("0"), + PARTITION `p1` VALUES LESS THAN ("2") + ) + DISTRIBUTED BY HASH(`id`) BUCKETS 2 + PROPERTIES ( + "replication_num" = "1" + ); + """ + + sql """ SET enable_insert_strict = true; """ + + // prepare data + sql """ + INSERT INTO ${srcName} (`id`, `score`) + VALUES (0, 9), (1, 7), (2, 10), (3, 6), (4, 5), (5, 8); + """ + sql """ + INSERT INTO ${srcName} SELECT * FROM ${srcName}; + """ + sql """ + INSERT INTO ${srcName} SELECT * FROM ${srcName}; + """ + sql """ + INSERT INTO ${srcName} SELECT * FROM ${srcName}; + """ + + expectExceptionLike({ + sql """ + INSERT INTO ${dstName} SELECT `id`, `score` FROM ${srcName}; + """ + }, "Insert has filtered data in strict mode. url: ") + + sql """ + INSERT INTO ${srcName} SELECT * FROM ${srcName}; + """ + + expectExceptionLike({ + sql """ + INSERT INTO ${dstName} SELECT `id`, `score` FROM ${srcName}; + """ + }, "[DATA_QUALITY_ERROR]Encountered unqualified data, stop processing. url: ") +} diff --git a/regression-test/suites/insert_p0/test_insert_strict_fail_url.groovy b/regression-test/suites/insert_p0/test_insert_strict_fail_url.groovy new file mode 100644 index 00000000000000..8d95a423cddc25 --- /dev/null +++ b/regression-test/suites/insert_p0/test_insert_strict_fail_url.groovy @@ -0,0 +1,87 @@ +// 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. + +import com.mysql.cj.jdbc.StatementImpl + +suite("test_insert_strict_fail_url") { + def dbName = "regression_test_insert_p0" + def srcTableName = "test_insert_strict_fail_url_src" + def dstTableName = "test_insert_strict_fail_url_dst" + def srcName = dbName + "." + srcTableName + def dstName = dbName + "." + dstTableName + + // create table + sql """ drop table if exists ${srcName}; """ + sql """ + CREATE TABLE ${srcName} ( + `key` int NOT NULL, + `id` int NULL, + `score` int NULL default "-1" + ) ENGINE=OLAP + DUPLICATE KEY(`key`) + DISTRIBUTED BY HASH(`key`) BUCKETS 1 + PROPERTIES ( + "replication_num" = "1" + ); + """ + + sql """ drop table if exists ${dstName}; """ + sql """ + CREATE TABLE ${dstName} ( + `id` int NOT NULL, + `score` int NULL default "-1" + ) ENGINE=OLAP + DUPLICATE KEY(`id`) + DISTRIBUTED BY HASH(`id`) BUCKETS 2 + PROPERTIES ( + "replication_num" = "1" + ); + """ + + sql """ SET enable_insert_strict = true; """ + + // prepare data + sql """ + INSERT INTO ${srcName} (`key`, `id`, `score`) + VALUES (0, 1, 9), (1, 2, 7), (2, NULL, 10), (3, NULL, 6), (4, NULL, 5), (5, NULL, 8); + """ + sql """ + INSERT INTO ${srcName} SELECT * FROM ${srcName}; + """ + sql """ + INSERT INTO ${srcName} SELECT * FROM ${srcName}; + """ + sql """ + INSERT INTO ${srcName} SELECT * FROM ${srcName}; + """ + + expectExceptionLike({ + sql """ + INSERT INTO ${dstName} SELECT `id`, `score` FROM ${srcName}; + """ + }, "Insert has filtered data in strict mode. url: ") + + sql """ + INSERT INTO ${srcName} SELECT * FROM ${srcName}; + """ + + expectExceptionLike({ + sql """ + INSERT INTO ${dstName} SELECT `id`, `score` FROM ${srcName}; + """ + }, "[DATA_QUALITY_ERROR]Encountered unqualified data, stop processing. url: ") +}