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

gavinchou pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new d4d08419f65 [test](doc) add some delete-example in doris's doc to 
regression test (#43148)
d4d08419f65 is described below

commit d4d08419f659e89430ac341c77fcfdff72d6e6fd
Author: yagagagaga <[email protected]>
AuthorDate: Mon Nov 11 11:12:52 2024 +0800

    [test](doc) add some delete-example in doris's doc to regression test 
(#43148)
---
 .../data-operate/delete/batch-delete-manual.md.out |  25 +++++
 .../doc/data-operate/delete/delete-manual.md.out   |   5 +
 .../delete/batch-delete-manual.md.groovy           | 120 +++++++++++++++++++++
 .../data-operate/delete/delete-manual.md.groovy    | 109 +++++++++++++++++++
 .../data-operate/delete/truncate-manual.md.groovy  |  43 ++++++++
 5 files changed, 302 insertions(+)

diff --git 
a/regression-test/data/doc/data-operate/delete/batch-delete-manual.md.out 
b/regression-test/data/doc/data-operate/delete/batch-delete-manual.md.out
new file mode 100644
index 00000000000..74cf8963bfb
--- /dev/null
+++ b/regression-test/data/doc/data-operate/delete/batch-delete-manual.md.out
@@ -0,0 +1,25 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !sql --
+3      2       tom     2
+4      3       bush    3
+5      3       helen   3
+
+-- !sql --
+4      3       bush    3
+5      3       helen   3
+
+-- !sql --
+2      1       grace   2
+3      2       tom     2
+4      3       bush    3
+5      3       helen   3
+
+-- !sql --
+wang   male    14      \N
+zhang  male    12      \N
+
+-- !sql --
+li     male    10      \N
+wang   male    14      \N
+zhang  male    12      \N
+
diff --git a/regression-test/data/doc/data-operate/delete/delete-manual.md.out 
b/regression-test/data/doc/data-operate/delete/delete-manual.md.out
new file mode 100644
index 00000000000..83a141b7228
--- /dev/null
+++ b/regression-test/data/doc/data-operate/delete/delete-manual.md.out
@@ -0,0 +1,5 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !sql --
+2      2       2       2.0     2000-01-02
+3      3       3       3.0     2000-01-03
+
diff --git 
a/regression-test/suites/doc/data-operate/delete/batch-delete-manual.md.groovy 
b/regression-test/suites/doc/data-operate/delete/batch-delete-manual.md.groovy
new file mode 100644
index 00000000000..7d15e34f514
--- /dev/null
+++ 
b/regression-test/suites/doc/data-operate/delete/batch-delete-manual.md.groovy
@@ -0,0 +1,120 @@
+// 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 org.junit.jupiter.api.Assertions;
+
+suite("docs/data-operate/delete/batch-delete-manual.md") {
+    def writeToFile = {String path, String data ->
+        OutputStreamWriter w = null
+        try {
+            w = new OutputStreamWriter(new FileOutputStream(path))
+            w.write(data)
+            w.flush()
+            w.close()
+        } finally {
+            if (w != null) w.close()
+        }
+    }
+    try {
+        multi_sql """
+            CREATE DATABASE IF NOT EXISTS test;
+            USE test;
+            DROP TABLE IF EXISTS table1;
+            CREATE TABLE IF NOT EXISTS table1 (
+                siteid INT,
+                citycode INT,
+                username VARCHAR(64),
+                pv BIGINT
+            ) UNIQUE KEY (siteid, citycode, username)
+            DISTRIBUTED BY HASH(siteid) BUCKETS 1
+            PROPERTIES (
+                "replication_num" = "1"
+            );
+        """
+        multi_sql """
+            SET show_hidden_columns=true;
+            DESC table1;
+            SET show_hidden_columns=false;
+        """
+
+        writeToFile("${context.file.parent}/table1_data", """\
+3,2,tom,2
+4,3,bush,3
+5,3,helen,3
+""")
+        println (cmd """curl --location-trusted -u 
${context.config.jdbcUser}:${context.config.jdbcPassword} -H 
"column_separator:," -H "columns: siteid, citycode, username, pv" -H 
"merge_type: APPEND"  -T ${context.file.parent}/table1_data 
http://${context.config.feHttpAddress}/api/test/table1/_stream_load""";)
+        println (cmd """curl --location-trusted -u 
${context.config.jdbcUser}:${context.config.jdbcPassword} -H 
"column_separator:," -H "columns: siteid, citycode, username, pv" -T 
${context.file.parent}/table1_data 
http://${context.config.feHttpAddress}/api/test/table1/_stream_load""";)
+        order_qt_sql "SELECT * FROM test.table1"
+
+        writeToFile("${context.file.parent}/table1_data", """\
+3,2,tom,0
+""")
+        println (cmd """curl --location-trusted -u 
${context.config.jdbcUser}:${context.config.jdbcPassword} -H 
"column_separator:," -H "columns: siteid, citycode, username, pv" -H 
"merge_type: DELETE"  -T ${context.file.parent}/table1_data 
http://${context.config.feHttpAddress}/api/test/table1/_stream_load""";)
+        order_qt_sql "SELECT * FROM test.table1"
+
+        multi_sql """
+            TRUNCATE TABLE table1;
+            INSERT INTO table1(siteid, citycode, username, pv) VALUES
+                              (     4,        3, 'bush'  ,  3),
+                              (     5,        3, 'helen' ,  3),
+                              (     1,        1, 'jim'   ,  2);
+        """
+        writeToFile("${context.file.parent}/table1_data", """\
+2,1,grace,2
+3,2,tom,2
+1,1,jim,2
+""")
+        println (cmd """curl --location-trusted -u 
${context.config.jdbcUser}:${context.config.jdbcPassword} -H 
"column_separator:," -H "columns: siteid, citycode, username, pv" -H 
"merge_type: MERGE" -H "delete: siteid=1"  -T 
${context.file.parent}/table1_data 
http://${context.config.feHttpAddress}/api/test/table1/_stream_load""";)
+        order_qt_sql "SELECT * FROM test.table1"
+
+        multi_sql """
+            DROP TABLE IF EXISTS table1;
+            CREATE TABLE IF NOT EXISTS table1 (
+                name VARCHAR(100) NOT NULL,
+                gender VARCHAR(10),
+                age INT,
+                pv BIGINT
+            ) UNIQUE KEY (name)
+            DISTRIBUTED BY HASH(name) BUCKETS 1
+            PROPERTIES (
+                "function_column.sequence_col" = "age",
+                "replication_num" = "1"
+            );
+            INSERT INTO table1(name, gender, age) VALUES
+                              ('li', 'male', 10),
+                              ('wang', 'male', 14),
+                              ('zhang', 'male', 12);
+            SET show_hidden_columns=true;
+            DESC table1;
+            SET show_hidden_columns=false;
+        """
+        writeToFile("${context.file.parent}/table1_data", """\
+li,male,10
+""")
+        println (cmd """curl --location-trusted -u 
${context.config.jdbcUser}:${context.config.jdbcPassword} -H 
"column_separator:," -H "columns: name, gender, age" -H 
"function_column.sequence_col: age" -H "merge_type: DELETE"  -T 
${context.file.parent}/table1_data 
http://${context.config.feHttpAddress}/api/test/table1/_stream_load""";)
+        order_qt_sql "SELECT * FROM test.table1"
+
+        sql """INSERT INTO table1(name, gender, age) VALUES ('li', 'male', 
10);"""
+        writeToFile("${context.file.parent}/table1_data", """\
+li,male,9
+""")
+        println (cmd """curl --location-trusted -u 
${context.config.jdbcUser}:${context.config.jdbcPassword} -H 
"column_separator:," -H "columns: name, gender, age" -H 
"function_column.sequence_col: age" -H "merge_type: DELETE"  -T 
${context.file.parent}/table1_data 
http://${context.config.feHttpAddress}/api/test/table1/_stream_load""";)
+        order_qt_sql "SELECT * FROM test.table1"
+    } catch (Throwable t) {
+        Assertions.fail("examples in 
docs/data-operate/delete/batch-delete-manual.md failed to exec, please fix it", 
t)
+    }
+}
diff --git 
a/regression-test/suites/doc/data-operate/delete/delete-manual.md.groovy 
b/regression-test/suites/doc/data-operate/delete/delete-manual.md.groovy
new file mode 100644
index 00000000000..4ba995e664c
--- /dev/null
+++ b/regression-test/suites/doc/data-operate/delete/delete-manual.md.groovy
@@ -0,0 +1,109 @@
+// 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 org.junit.jupiter.api.Assertions;
+
+suite("docs/data-operate/delete/delete-manual.md") {
+    try {
+        multi_sql """
+            CREATE DATABASE IF NOT EXISTS test_db;
+            USE test_db;
+            DROP TABLE IF EXISTS my_table;
+            CREATE TABLE IF NOT EXISTS my_table(
+                k1 INT,
+                k2 STRING
+            )
+            PARTITION BY RANGE(k1) (
+                PARTITION p1 VALUES LESS THAN (1),
+                PARTITION p2 VALUES LESS THAN (2)
+            )
+            DISTRIBUTED BY HASH(k1) BUCKETS 1
+            PROPERTIES (
+                "replication_num" = "1"
+            );
+        """
+
+        sql """
+            DELETE FROM my_table PARTITION p1
+                WHERE k1 = 3;
+        """
+        sql """
+            DELETE FROM my_table PARTITION p1
+            WHERE k1 = 3 AND k2 = "abc";
+        """
+        sql """
+            DELETE FROM my_table PARTITIONS (p1, p2)
+            WHERE k1 = 3 AND k2 = "abc";
+        """
+
+        multi_sql """
+            DROP TABLE IF EXISTS t1;
+            DROP TABLE IF EXISTS t2;
+            DROP TABLE IF EXISTS t3;
+        """
+        multi_sql """
+            -- Create t1, t2, t3 tables
+            CREATE TABLE t1
+              (id INT, c1 BIGINT, c2 STRING, c3 DOUBLE, c4 DATE)
+            UNIQUE KEY (id)
+            DISTRIBUTED BY HASH (id)
+            PROPERTIES('replication_num'='1', "function_column.sequence_col" = 
"c4");
+            
+            CREATE TABLE t2
+              (id INT, c1 BIGINT, c2 STRING, c3 DOUBLE, c4 DATE)
+            DISTRIBUTED BY HASH (id)
+            PROPERTIES('replication_num'='1');
+            
+            CREATE TABLE t3
+              (id INT)
+            DISTRIBUTED BY HASH (id)
+            PROPERTIES('replication_num'='1');
+            
+            -- insert data
+            INSERT INTO t1 VALUES
+              (1, 1, '1', 1.0, '2000-01-01'),
+              (2, 2, '2', 2.0, '2000-01-02'),
+              (3, 3, '3', 3.0, '2000-01-03');
+            
+            INSERT INTO t2 VALUES
+              (1, 10, '10', 10.0, '2000-01-10'),
+              (2, 20, '20', 20.0, '2000-01-20'),
+              (3, 30, '30', 30.0, '2000-01-30'),
+              (4, 4, '4', 4.0, '2000-01-04'),
+              (5, 5, '5', 5.0, '2000-01-05');
+            
+            INSERT INTO t3 VALUES
+              (1),
+              (4),
+              (5);
+            
+            -- remove rows from t1
+            DELETE FROM t1
+              USING t2 INNER JOIN t3 ON t2.id = t3.id
+              WHERE t1.id = t2.id;
+        """
+        order_qt_sql "SELECT * FROM t1"
+
+        sql "DROP TABLE IF EXISTS test_tbl"
+        sql "CREATE TABLE IF NOT EXISTS test_tbl LIKE my_table"
+        sql "delete from test_tbl PARTITION p1 where k1 = 1;"
+        sql "delete from test_tbl partition p1 where k1 > 80;"
+        sql "show delete from test_db;"
+    } catch (Throwable t) {
+        Assertions.fail("examples in docs/data-operate/delete/delete-manual.md 
failed to exec, please fix it", t)
+    }
+}
diff --git 
a/regression-test/suites/doc/data-operate/delete/truncate-manual.md.groovy 
b/regression-test/suites/doc/data-operate/delete/truncate-manual.md.groovy
new file mode 100644
index 00000000000..08012971d10
--- /dev/null
+++ b/regression-test/suites/doc/data-operate/delete/truncate-manual.md.groovy
@@ -0,0 +1,43 @@
+// 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 org.junit.jupiter.api.Assertions;
+
+suite("docs/data-operate/delete/truncate-manual.md") {
+    try {
+        multi_sql """
+            CREATE DATABASE IF NOT EXISTS example_db;
+            USE example_db;
+            CREATE TABLE IF NOT EXISTS tbl(
+                a INT
+            )
+            PARTITION BY RANGE(a) (
+                PARTITION p1 VALUES LESS THAN (1),
+                PARTITION p2 VALUES LESS THAN (2)
+            )
+            DISTRIBUTED BY RANDOM BUCKETS 1
+            PROPERTIES (
+                "replication_num" = "1"
+            );
+        """
+
+        sql "TRUNCATE TABLE example_db.tbl;"
+        sql "TRUNCATE TABLE tbl PARTITION(p1, p2);"
+    } catch (Throwable t) {
+        Assertions.fail("examples in 
docs/data-operate/delete/truncate-manual.md failed to exec, please fix it", t)
+    }
+}


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

Reply via email to