This is an automated email from the ASF dual-hosted git repository.

liaoxin pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.1 by this push:
     new 47096f20830 [test](regression) add cases for data quality error url 
(#34987) (#37777)
47096f20830 is described below

commit 47096f20830eaab3c62515709223d9ef7f6227fb
Author: Kaijie Chen <[email protected]>
AuthorDate: Tue Jul 16 11:12:52 2024 +0800

    [test](regression) add cases for data quality error url (#34987) (#37777)
    
    cherry-pick #34987
---
 be/src/common/status.h                             |  5 +-
 be/src/vec/sink/vtablet_finder.cpp                 |  4 +-
 .../org/apache/doris/regression/suite/Suite.groovy | 10 +++
 .../test_insert_partition_fail_url.groovy          | 91 ++++++++++++++++++++++
 .../insert_p0/test_insert_strict_fail_url.groovy   | 87 +++++++++++++++++++++
 5 files changed, 191 insertions(+), 6 deletions(-)

diff --git a/be/src/common/status.h b/be/src/common/status.h
index c4692392415..94988cbdae3 100644
--- a/be/src/common/status.h
+++ b/be/src/common/status.h
@@ -602,10 +602,7 @@ inline std::string Status::to_string() const {
 }
 
 inline std::string Status::to_string_no_stack() const {
-    std::stringstream ss;
-    ss << '[' << code_as_string() << ']';
-    ss << msg();
-    return ss.str();
+    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 2e0d278fa4f..3bfd5bb4d22 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/framework/src/main/groovy/org/apache/doris/regression/suite/Suite.groovy
 
b/regression-test/framework/src/main/groovy/org/apache/doris/regression/suite/Suite.groovy
index 0d521658999..97d0c1868e9 100644
--- 
a/regression-test/framework/src/main/groovy/org/apache/doris/regression/suite/Suite.groovy
+++ 
b/regression-test/framework/src/main/groovy/org/apache/doris/regression/suite/Suite.groovy
@@ -649,6 +649,16 @@ class Suite implements GroovyInterceptable {
         }
     }
 
+    void expectExceptionLike(Closure userFunction, String errorMessage = null) 
{
+        try {
+            userFunction()
+        } catch (Exception e) {
+            if (!e.getMessage().contains(errorMessage)) {
+                throw e
+            }
+        }
+    }
+
     String getBrokerName() {
         String brokerName = context.config.otherConfigs.get("brokerName")
         return brokerName
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 00000000000..dae6e86e525
--- /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};
+        """
+    }, "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 00000000000..8d95a423cdd
--- /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: ")
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to