eldenmoon commented on code in PR #56208:
URL: https://github.com/apache/doris/pull/56208#discussion_r2361632437


##########
regression-test/suites/datatype_p0/complex_types/test_all_escape_sequences.groovy:
##########
@@ -0,0 +1,282 @@
+// 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_all_escape_sequences") {
+    sql "DROP TABLE IF EXISTS `escape_sequences_test`"
+    sql """
+        create table IF NOT EXISTS `escape_sequences_test` (
+                `id` int NULL,
+                `test_name` text NULL,
+                `arr` array<text> NULL,
+                `map_col` map<string, text> NULL,
+                `struct_col` struct<name:text, des:text> NULL
+        ) ENGINE=OLAP
+          DUPLICATE KEY(`id`)  distributed by hash(`id`) buckets 1 
properties("replication_num" = "1");
+    """
+
+    // 测试用例1: 双引号转义 \" - Insert Values测试
+    sql """
+        INSERT INTO escape_sequences_test VALUES 
+        (1, 'double_quote_test', 
'["normal","with\\"quotes\\"","end\\"quote"]', 
+         '{"key1":"value1","key2":"with\\"quotes\\"","key3":"end\\"quote"}', 
+         '{"name":"test","des":"with\\"quotes\\"and\\"more\\"quotes"}'),
+        (2, 'double_quote_map', NULL, 
+         '{"key1":"value1","key2":"with\\"quotes\\"","key3":"end\\"quote"}', 
+         NULL),
+        (3, 'double_quote_struct', NULL, NULL, 
+         '{"name":"test","des":"with\\"quotes\\"and\\"more\\"quotes"}')
+    """
+    
+    qt_select_double_quote """
+        SELECT id, test_name, arr, map_col, struct_col FROM 
escape_sequences_test WHERE id <= 3 ORDER BY id
+    """
+    qt_select_double_quote_array_size """
+        SELECT id, test_name, array_size(arr) FROM escape_sequences_test WHERE 
id <= 3 ORDER BY id
+    """
+    qt_select_double_quote_map_size """
+        SELECT id, test_name, map_size(map_col) FROM escape_sequences_test 
WHERE id <= 3 ORDER BY id
+    """
+
+    // 测试用例2: 反斜杠转义 \\ - Insert Values测试
+    sql """
+        INSERT INTO escape_sequences_test VALUES 
+        (4, 'backslash_test', 
'["normal","with\\\\backslash","end\\\\backslash"]', 
+         
'{"key1":"value1","key2":"with\\\\backslash","key3":"end\\\\backslash"}', 
+         
'{"name":"test","des":"with\\\\backslash\\\\and\\\\more\\\\backslashes"}'),
+        (5, 'backslash_map', NULL, 
+         
'{"key1":"value1","key2":"with\\\\backslash","key3":"end\\\\backslash"}', 
+         NULL),
+        (6, 'backslash_struct', NULL, NULL, 
+         
'{"name":"test","des":"with\\\\backslash\\\\and\\\\more\\\\backslashes"}')
+    """
+    
+    qt_select_backslash """
+        SELECT id, test_name, arr, map_col, struct_col FROM 
escape_sequences_test WHERE id BETWEEN 4 AND 6 ORDER BY id
+    """
+    qt_select_backslash_array_size """
+        SELECT id, test_name, array_size(arr) FROM escape_sequences_test WHERE 
id BETWEEN 4 AND 6 ORDER BY id
+    """
+    qt_select_backslash_map_size """
+        SELECT id, test_name, map_size(map_col) FROM escape_sequences_test 
WHERE id BETWEEN 4 AND 6 ORDER BY id
+    """
+    // 测试用例3: 换行符转义 \n - Insert Values测试
+    sql """
+        INSERT INTO escape_sequences_test VALUES 
+        (7, 'newline_test', '["normal","with\\nnewline","end\\nnewline"]', 
+         '{"key1":"value1","key2":"with\\nnewline","key3":"end\\nnewline"}', 
+         '{"name":"test","des":"with\\nnewline\\nand\\nmore\\nnewlines"}'),
+        (8, 'newline_map', NULL, 
+         '{"key1":"value1","key2":"with\\nnewline","key3":"end\\nnewline"}', 
+         NULL),
+        (9, 'newline_struct', NULL, NULL, 
+         '{"name":"test","des":"with\\nnewline\\nand\\nmore\\nnewlines"}')
+    """
+    
+    qt_select_newline """
+        SELECT id, test_name, arr, map_col, struct_col FROM 
escape_sequences_test WHERE id BETWEEN 7 AND 9 ORDER BY id
+    """
+    qt_select_newline_array_size """
+        SELECT id, test_name, array_size(arr) FROM escape_sequences_test WHERE 
id BETWEEN 7 AND 9 ORDER BY id
+    """
+    qt_select_newline_map_size """
+        SELECT id, test_name, map_size(map_col) FROM escape_sequences_test 
WHERE id BETWEEN 7 AND 9 ORDER BY id
+    """
+    // 测试用例4: 制表符转义 \t - Insert Values测试
+    sql """
+        INSERT INTO escape_sequences_test VALUES 
+        (10, 'tab_test', '["normal","with\\ttab","end\\ttab"]', 
+         '{"key1":"value1","key2":"with\\ttab","key3":"end\\ttab"}', 
+         '{"name":"test","des":"with\\ttab\\tand\\tmore\\ttabs"}'),
+        (11, 'tab_map', NULL, 
+         '{"key1":"value1","key2":"with\\ttab","key3":"end\\ttab"}', 
+         NULL),
+        (12, 'tab_struct', NULL, NULL, 
+         '{"name":"test","des":"with\\ttab\\tand\\tmore\\ttabs"}')
+    """
+    
+    qt_select_tab """
+        SELECT id, test_name, arr, map_col, struct_col FROM 
escape_sequences_test WHERE id BETWEEN 10 AND 12 ORDER BY id
+    """
+    qt_select_tab_array_size """
+        SELECT id, test_name, array_size(arr) FROM escape_sequences_test WHERE 
id BETWEEN 10 AND 12 ORDER BY id
+    """
+    qt_select_tab_map_size """
+        SELECT id, test_name, map_size(map_col) FROM escape_sequences_test 
WHERE id BETWEEN 10 AND 12 ORDER BY id
+    """
+    // 测试用例5: 回车符转义 \r - Insert Values测试
+    sql """
+        INSERT INTO escape_sequences_test VALUES 
+        (13, 'carriage_return_test', 
'["normal","with\\rcarriage","end\\rcarriage"]', 
+         '{"key1":"value1","key2":"with\\rcarriage","key3":"end\\rcarriage"}', 
+         '{"name":"test","des":"with\\rcarriage\\rand\\rmore\\rcarriages"}'),
+        (14, 'carriage_return_map', NULL, 
+         '{"key1":"value1","key2":"with\\rcarriage","key3":"end\\rcarriage"}', 
+         NULL),
+        (15, 'carriage_return_struct', NULL, NULL, 
+         '{"name":"test","des":"with\\rcarriage\\rand\\rmore\\rcarriages"}')
+    """
+    
+    qt_select_carriage_return """
+        SELECT id, test_name, arr, map_col, struct_col FROM 
escape_sequences_test WHERE id BETWEEN 13 AND 15 ORDER BY id
+    """
+    qt_select_carriage_return_array_size """
+        SELECT id, test_name, array_size(arr) FROM escape_sequences_test WHERE 
id BETWEEN 13 AND 15 ORDER BY id
+    """
+    qt_select_carriage_return_map_size """
+        SELECT id, test_name, map_size(map_col) FROM escape_sequences_test 
WHERE id BETWEEN 13 AND 15 ORDER BY id
+    """
+    // 测试用例6: 退格符转义 \b - Insert Values测试
+    sql """
+        INSERT INTO escape_sequences_test VALUES 

Review Comment:
   add stream load case for json format



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to