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

gabriellee 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 b6e20db997 [fix](outfile) select OBJECT and HLL columns into outfile 
as null. (#12734)
b6e20db997 is described below

commit b6e20db997849f0b128760fb01afbf19d19e9b5d
Author: luozenglin <[email protected]>
AuthorDate: Wed Sep 21 11:24:31 2022 +0800

    [fix](outfile) select OBJECT and HLL columns into outfile as null. (#12734)
---
 be/src/vec/runtime/vfile_result_writer.cpp         | 10 ++++-
 .../suites/export_p0/test_outfile.groovy           | 52 ++++++++++++++++++++++
 2 files changed, 60 insertions(+), 2 deletions(-)

diff --git a/be/src/vec/runtime/vfile_result_writer.cpp 
b/be/src/vec/runtime/vfile_result_writer.cpp
index bc0ebe61ed..af4319a91a 100644
--- a/be/src/vec/runtime/vfile_result_writer.cpp
+++ b/be/src/vec/runtime/vfile_result_writer.cpp
@@ -293,7 +293,13 @@ Status VFileResultWriter::_write_csv_file(const Block& 
block) {
                     break;
                 }
                 case TYPE_OBJECT:
-                case TYPE_HLL:
+                case TYPE_HLL: {
+                    if (!_output_object_data) {
+                        _plain_text_outstream << NULL_IN_CSV;
+                        break;
+                    }
+                    [[fallthrough]];
+                }
                 case TYPE_VARCHAR:
                 case TYPE_CHAR:
                 case TYPE_STRING: {
@@ -327,7 +333,7 @@ Status VFileResultWriter::_write_csv_file(const Block& 
block) {
                     break;
                 }
                 default: {
-                    // not supported type, like BITMAP, HLL, just export null
+                    // not supported type, like BITMAP, just export null
                     _plain_text_outstream << NULL_IN_CSV;
                 }
                 }
diff --git a/regression-test/suites/export_p0/test_outfile.groovy 
b/regression-test/suites/export_p0/test_outfile.groovy
index 1cf281316c..91ab0ef0a9 100644
--- a/regression-test/suites/export_p0/test_outfile.groovy
+++ b/regression-test/suites/export_p0/test_outfile.groovy
@@ -132,4 +132,56 @@ suite("test_outfile") {
         }
     }
 
+    // test hll column outfile
+    try {
+        sql """ DROP TABLE IF EXISTS ${tableName} """
+        sql """
+        CREATE TABLE ${tableName} (
+          `k1` int(11) NOT NULL,
+          `v1` hll HLL_UNION NOT NULL,
+          `v2` int(11) SUM NOT NULL
+        ) ENGINE=OLAP
+        AGGREGATE KEY(`k1`)
+        COMMENT 'OLAP'
+        DISTRIBUTED BY HASH(`k1`) BUCKETS 2
+        PROPERTIES (
+        "replication_allocation" = "tag.location.default: 1"
+        );
+        """
+
+        sql """
+            insert into ${tableName} values (7483648, hll_hash(7483648), 1), 
(7483648, hll_hash(7483648), 1), 
+            (706432 , hll_hash(706432 ), 1), (706432 , hll_hash(706432 ), 1)
+        """
+
+        File path = new File(outFilePath)
+        if (!path.exists()) {
+            assert path.mkdirs()
+        } else {
+            throw new IllegalStateException("""${outFilePath} already exists! 
""")
+        }
+
+        sql "set return_object_data_as_binary = false"
+        sql """
+            SELECT * FROM ${tableName} t ORDER BY k1, v2 INTO OUTFILE 
"file://${outFilePath}/";
+        """
+
+        File[] files = path.listFiles()
+        assert files.length == 1
+        List<String> outLines = 
Files.readAllLines(Paths.get(files[0].getAbsolutePath()), 
StandardCharsets.UTF_8);
+        assertEquals(2, outLines.size())
+        String[] outLine1 = outLines.get(0).split("\t")
+        assertEquals(3, outLine1.size())
+        assert outLine1[1] == "\\N"
+        assert outLines.get(1).split("\t")[1] == "\\N"
+    } finally {
+        try_sql("DROP TABLE IF EXISTS ${tableName}")
+        File path = new File(outFilePath)
+        if (path.exists()) {
+            for (File f: path.listFiles()) {
+                f.delete();
+            }
+            path.delete();
+        }
+    }
 }


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

Reply via email to