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

morningman 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 cf40dba7fba [fix](outfile) add regression test for outfile (#44734)
cf40dba7fba is described below

commit cf40dba7fba7ca258d3ee7b6275ded1a4cc345ea
Author: Tiewei Fang <fangtie...@selectdb.com>
AuthorDate: Sat Nov 30 09:18:53 2024 +0800

    [fix](outfile) add regression test for outfile (#44734)
    
    ### What problem does this PR solve?
    Problem Summary:
    
    add regression test for this pr: #43929
    
    TODO:
    Support to export data of doris NULL type to orc file format.
---
 .../export_p0/outfile/test_outfile_null_type.out   |  37 +++++++
 .../outfile/test_outfile_null_type.groovy          | 111 +++++++++++++++++++++
 2 files changed, 148 insertions(+)

diff --git a/regression-test/data/export_p0/outfile/test_outfile_null_type.out 
b/regression-test/data/export_p0/outfile/test_outfile_null_type.out
new file mode 100644
index 00000000000..1777bba72c1
--- /dev/null
+++ b/regression-test/data/export_p0/outfile/test_outfile_null_type.out
@@ -0,0 +1,37 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !select_export --
+1      ftw-1   19
+2      ftw-2   20
+3      ftw-3   21
+4      ftw-4   22
+5      ftw-5   23
+6      ftw-6   24
+7      ftw-7   25
+8      ftw-8   26
+9      ftw-9   27
+10     \N      \N
+
+-- !select_load_parquet --
+1      ftw-1   19      \N
+10     \N      \N      \N
+2      ftw-2   20      \N
+3      ftw-3   21      \N
+4      ftw-4   22      \N
+5      ftw-5   23      \N
+6      ftw-6   24      \N
+7      ftw-7   25      \N
+8      ftw-8   26      \N
+9      ftw-9   27      \N
+
+-- !select_load_csv --
+1      ftw-1   19      \N
+10     \N      \N      \N
+2      ftw-2   20      \N
+3      ftw-3   21      \N
+4      ftw-4   22      \N
+5      ftw-5   23      \N
+6      ftw-6   24      \N
+7      ftw-7   25      \N
+8      ftw-8   26      \N
+9      ftw-9   27      \N
+
diff --git 
a/regression-test/suites/export_p0/outfile/test_outfile_null_type.groovy 
b/regression-test/suites/export_p0/outfile/test_outfile_null_type.groovy
new file mode 100644
index 00000000000..492b6770195
--- /dev/null
+++ b/regression-test/suites/export_p0/outfile/test_outfile_null_type.groovy
@@ -0,0 +1,111 @@
+// 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.
+
+suite("test_outfile_null_type", "p0") {
+    String ak = getS3AK()
+    String sk = getS3SK()
+    String s3_endpoint = getS3Endpoint()
+    String region = getS3Region()
+    String bucket = context.config.otherConfigs.get("s3BucketName");
+
+    def export_table_name = "test_outfile_null_type"
+    def outFilePath = "${bucket}/outfile/null_type/exp_"
+
+    def outfile_to_S3 = { format ->
+        // select ... into outfile ...
+        def res = sql """
+            SELECT *, NULL AS null_col FROM ${export_table_name} t
+            INTO OUTFILE "s3://${outFilePath}"
+            FORMAT AS ${format}
+            PROPERTIES (
+                "s3.endpoint" = "${s3_endpoint}",
+                "s3.region" = "${region}",
+                "s3.secret_key"="${sk}",
+                "s3.access_key" = "${ak}"
+            );
+        """
+
+        return res[0][3]
+    }
+
+    sql """ DROP TABLE IF EXISTS ${export_table_name} """
+    sql """
+        CREATE TABLE `${export_table_name}` (
+            `id` int(11) NULL,
+            `Name` string NULL,
+            `age` int(11) NULL
+        ) ENGINE=OLAP
+        DISTRIBUTED BY HASH(`id`)
+        PROPERTIES (
+            "replication_num" = "1"
+        );
+        """
+
+    StringBuilder sb = new StringBuilder()
+    int i = 1
+    for (; i < 10; i ++) {
+        sb.append("""
+            (${i}, 'ftw-${i}', ${i + 18}),
+        """)
+    }
+    sb.append("""
+            (${i}, NULL, NULL)
+        """)
+    sql """ INSERT INTO ${export_table_name} VALUES
+            ${sb.toString()}
+        """
+    def insert_res = sql "show last insert;"
+    logger.info("insert result: " + insert_res.toString())
+    qt_select_export """ SELECT * FROM ${export_table_name} t ORDER BY id; """
+
+    // parquet file format
+    def format = "parquet"
+    def outfile_url = outfile_to_S3("${format}")
+    order_qt_select_load_parquet """ SELECT * FROM S3 (
+                "uri" = 
"http://${bucket}.${s3_endpoint}${outfile_url.substring(5 + bucket.length(), 
outfile_url.length() - 1)}0.${format}",
+                "ACCESS_KEY"= "${ak}",
+                "SECRET_KEY" = "${sk}",
+                "format" = "${format}",
+                "region" = "${region}"
+            );
+            """
+
+    // TODO(ftw): orc supports to export data of NULL type.
+    // orc file foramt
+    // format = "orc"
+    // outfile_url = outfile_to_S3("${format}")
+    // qt_select_load_orc """ SELECT * FROM S3 (
+    //             "uri" = 
"http://${bucket}.${s3_endpoint}${outfile_url.substring(5 + bucket.length(), 
outfile_url.length() - 1)}0.${format}",
+    //             "ACCESS_KEY"= "${ak}",
+    //             "SECRET_KEY" = "${sk}",
+    //             "format" = "${format}",
+    //             "region" = "${region}"
+    //         );
+    //         """
+
+    // csv file foramt
+    format = "csv"
+    outfile_url = outfile_to_S3("${format}")
+    order_qt_select_load_csv """ SELECT * FROM S3 (
+                "uri" = 
"http://${bucket}.${s3_endpoint}${outfile_url.substring(5 + bucket.length(), 
outfile_url.length() - 1)}0.${format}",
+                "ACCESS_KEY"= "${ak}",
+                "SECRET_KEY" = "${sk}",
+                "format" = "${format}",
+                "region" = "${region}"
+            );
+            """
+}
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to