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

yiguolei 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 4ecaa921f98 [regression-test](num_as_string) test num_as_string 
(#26842)
4ecaa921f98 is described below

commit 4ecaa921f9841f5c643e93a589547cd8db495d48
Author: Guangdong Liu <[email protected]>
AuthorDate: Mon Nov 13 21:48:13 2023 +0800

    [regression-test](num_as_string) test num_as_string (#26842)
---
 .../data/load_p0/stream_load/num_as_string.json    | 17 +++++
 .../data/load_p0/stream_load/test_stream_load.out  | 10 +++
 .../load_p0/stream_load/test_stream_load.groovy    | 78 +++++++++++++++++++---
 3 files changed, 97 insertions(+), 8 deletions(-)

diff --git a/regression-test/data/load_p0/stream_load/num_as_string.json 
b/regression-test/data/load_p0/stream_load/num_as_string.json
new file mode 100644
index 00000000000..8ed315fd5cf
--- /dev/null
+++ b/regression-test/data/load_p0/stream_load/num_as_string.json
@@ -0,0 +1,17 @@
+[
+  {
+    "k1": 10,
+    "k2": 1.23,
+    "k3": 3.14159
+  },
+  {
+    "k1": 20,
+    "k2": 4.56,
+    "k3": 2.71828
+  },
+  {
+    "k1": 30,
+    "k2": 7.89,
+    "k3": 1.61803
+  }
+]
diff --git a/regression-test/data/load_p0/stream_load/test_stream_load.out 
b/regression-test/data/load_p0/stream_load/test_stream_load.out
index 8c88c4f5dc2..71e0166fef4 100644
--- a/regression-test/data/load_p0/stream_load/test_stream_load.out
+++ b/regression-test/data/load_p0/stream_load/test_stream_load.out
@@ -6,6 +6,16 @@
 -- !sql1 --
 2019   9       9       9       7.700   a       2019-09-09      
1970-01-01T08:33:39     k7      9.0     9.0
 
+-- !num_as_string --
+10     1.23    3.14159
+20     4.56    2.71828
+30     7.89    1.61803
+
+-- !num_as_string_false --
+10     1.23    3.14159
+20     4.56    2.71828
+30     7.89    1.61803
+
 -- !map11 --
 1      {1:"1", 2:"22", 3:"333", 4:"4444", 5:"55555", 6:"666666", 7:"7777777"}
 2      {1:"1", 2:"2", 3:"3", 4:"4", 5:"5", 6:"6", 7:"7"}
diff --git a/regression-test/suites/load_p0/stream_load/test_stream_load.groovy 
b/regression-test/suites/load_p0/stream_load/test_stream_load.groovy
index 35a7ef60ed0..dc6060d44d5 100644
--- a/regression-test/suites/load_p0/stream_load/test_stream_load.groovy
+++ b/regression-test/suites/load_p0/stream_load/test_stream_load.groovy
@@ -54,7 +54,7 @@ suite("test_stream_load", "p0") {
         DISTRIBUTED BY HASH(`k1`, `k2`) BUCKETS 3
         PROPERTIES ("replication_allocation" = "tag.location.default: 1");
     """
-    
+
     // test strict_mode success
     streamLoad {
         table "${tableName}"
@@ -196,6 +196,7 @@ suite("test_stream_load", "p0") {
     def tableName8 = "test_array"
     def tableName10 = "test_struct"
     def tableName11 = "test_map"
+    def tableName12 = "test_num_as_string"
 
     sql """ DROP TABLE IF EXISTS ${tableName3} """
     sql """ DROP TABLE IF EXISTS ${tableName4} """
@@ -205,6 +206,7 @@ suite("test_stream_load", "p0") {
     sql """ DROP TABLE IF EXISTS ${tableName8} """
     sql """ DROP TABLE IF EXISTS ${tableName10} """
     sql """ DROP TABLE IF EXISTS ${tableName11} """
+    sql """ DROP TABLE IF EXISTS ${tableName12} """
     sql """
     CREATE TABLE IF NOT EXISTS ${tableName3} (
       `k1` int(11) NULL,
@@ -335,6 +337,66 @@ suite("test_stream_load", "p0") {
     );
     """
 
+    sql """
+    CREATE TABLE IF NOT EXISTS ${tableName12} (
+      `k1` int(11) NULL,
+      `k2` float NULL,
+      `k3` double NULL
+    ) ENGINE=OLAP
+    DUPLICATE KEY(`k1`)
+    DISTRIBUTED BY HASH(`k1`) BUCKETS 3
+    PROPERTIES (
+    "replication_allocation" = "tag.location.default: 1"
+    );
+    """
+
+    // test num_as_string
+    streamLoad {
+        table "${tableName12}"
+
+        set 'format', 'JSON'
+        set 'num_as_string', 'true'
+        set 'strip_outer_array', 'true'
+        file 'num_as_string.json'
+        time 10000 // limit inflight 10s
+
+        check { result, exception, startTime, endTime ->
+            if (exception != null) {
+                throw exception
+            }
+            log.info("Stream load result: ${result}".toString())
+            def json = parseJson(result)
+            assertEquals("success", json.Status.toLowerCase())
+        }
+    }
+    sql "sync"
+    order_qt_num_as_string "SELECT * FROM ${tableName12} order by k1"
+
+    sql """truncate table ${tableName12}"""
+    sql """sync"""
+
+
+    streamLoad {
+        table "${tableName12}"
+
+        set 'format', 'JSON'
+        set 'num_as_string', 'false'
+        set 'strip_outer_array', 'true'
+        file 'num_as_string.json'
+        time 10000 // limit inflight 10s
+
+        check { result, exception, startTime, endTime ->
+            if (exception != null) {
+                throw exception
+            }
+            log.info("Stream load result: ${result}".toString())
+            def json = parseJson(result)
+            assertEquals("success", json.Status.toLowerCase())
+        }
+    }
+    sql "sync"
+    qt_num_as_string_false "SELECT * FROM ${tableName12} order by k1"
+
     // load map with specific-length char with non-specific-length data
     streamLoad {
         table "${tableName11}"
@@ -356,7 +418,7 @@ suite("test_stream_load", "p0") {
         }
     }
     sql "sync"
-    order_qt_map11 "SELECT * FROM ${tableName11} order by k1" 
+    order_qt_map11 "SELECT * FROM ${tableName11} order by k1"
 
     // load all columns
     streamLoad {
@@ -872,7 +934,7 @@ suite("test_stream_load", "p0") {
             assertEquals(5, json.NumberUnselectedRows)
         }
     }
-    
+
     sql "sync"
     order_qt_sql1 "select * from ${tableName9} order by k1, k2"
 
@@ -897,7 +959,7 @@ suite("test_stream_load", "p0") {
         DISTRIBUTED BY HASH(`k1`, `k2`) BUCKETS 3
         PROPERTIES ("replication_allocation" = "tag.location.default: 1");
     """
-    
+
     sql """create USER common_user@'%' IDENTIFIED BY '123456'"""
     sql """GRANT LOAD_PRIV ON *.* TO 'common_user'@'%';"""
 
@@ -924,7 +986,7 @@ suite("test_stream_load", "p0") {
             assertEquals(0, json.NumberUnselectedRows)
         }
     }
-    
+
     sql "sync"
     sql """DROP USER 'common_user'@'%'"""
 
@@ -1000,7 +1062,7 @@ suite("test_stream_load", "p0") {
             assert json.Message.contains("unknown data format")
         }
     }
-    
+
     sql "sync"
     def res = sql "select * from ${tableName14}"
     def time = res[0][5].toString().split("T")[0].split("-")
@@ -1083,7 +1145,7 @@ suite("test_stream_load", "p0") {
             PROPERTIES ("replication_allocation" = "tag.location.default: 1");
         """
 
-        def label = UUID.randomUUID().toString().replaceAll("-", "") 
+        def label = UUID.randomUUID().toString().replaceAll("-", "")
         streamLoad {
             table "${tableName15}"
 
@@ -1137,7 +1199,7 @@ suite("test_stream_load", "p0") {
         }
 
         do_streamload_2pc.call(label, "commit")
-        
+
         def count = 0
         while (true) {
             res = sql "select count(*) from ${tableName15}"


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

Reply via email to