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

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


The following commit(s) were added to refs/heads/master by this push:
     new 810aff0dc1e Support parsing Doris sql #31510 (#32184)
810aff0dc1e is described below

commit 810aff0dc1ef872f35cd14437087001ac0841cb3
Author: Skitii <[email protected]>
AuthorDate: Fri Jul 19 15:02:24 2024 +0800

    Support parsing Doris sql #31510 (#32184)
---
 .../resources/case/dml/select-special-function.xml | 45 ++++++++++++++++++++++
 .../sql/supported/dml/select-special-function.xml  |  4 ++
 .../main/resources/sql/supported/dml/select.xml    |  2 +-
 3 files changed, 50 insertions(+), 1 deletion(-)

diff --git 
a/test/it/parser/src/main/resources/case/dml/select-special-function.xml 
b/test/it/parser/src/main/resources/case/dml/select-special-function.xml
index abdd467db51..18902443b93 100644
--- a/test/it/parser/src/main/resources/case/dml/select-special-function.xml
+++ b/test/it/parser/src/main/resources/case/dml/select-special-function.xml
@@ -2448,4 +2448,49 @@
             </expression-projection>
         </projections>
     </select>
+
+    <select sql-case-id="select_json_parse">
+        <projections start-index="7" stop-index="41">
+            <expression-projection start-index="7" stop-index="41" 
text="JSON_PARSE('{&quot;k1&quot;:&quot;v31&quot;,&quot;k2&quot;:300}')">
+                <expr>
+                    <function function-name="JSON_PARSE" 
text="JSON_PARSE('{&quot;k1&quot;:&quot;v31&quot;,&quot;k2&quot;:300}')" 
start-index="7" stop-index="41">
+                        <parameter>
+                            <literal-expression 
value="{&quot;k1&quot;:&quot;v31&quot;,&quot;k2&quot;:300}" start-index="18" 
stop-index="40" />
+                        </parameter>
+                    </function>
+                </expr>
+            </expression-projection>
+        </projections>
+    </select>
+
+    <select sql-case-id="select_json_parse_error_to_null">
+        <projections start-index="7" stop-index="32">
+            <expression-projection start-index="7" stop-index="32" 
text="JSON_PARSE('invalid json')">
+                <expr>
+                    <function function-name="JSON_PARSE" 
text="JSON_PARSE('invalid json')" start-index="7" stop-index="32">
+                        <parameter>
+                            <literal-expression value="invalid json" 
start-index="18" stop-index="31" />
+                        </parameter>
+                    </function>
+                </expr>
+            </expression-projection>
+        </projections>
+    </select>
+
+    <select sql-case-id="select_json_parse_error_to_value">
+        <projections start-index="7" stop-index="38">
+            <expression-projection start-index="7" stop-index="38" 
text="JSON_PARSE('invalid json', '{}')">
+                <expr>
+                    <function function-name="JSON_PARSE" 
text="JSON_PARSE('invalid json', '{}')" start-index="7" stop-index="38">
+                        <parameter>
+                            <literal-expression value="invalid json" 
start-index="18" stop-index="31" />
+                        </parameter>
+                        <parameter>
+                            <literal-expression value="{}" start-index="34" 
stop-index="37" />
+                        </parameter>
+                    </function>
+                </expr>
+            </expression-projection>
+        </projections>
+    </select>
 </sql-parser-test-cases>
diff --git 
a/test/it/parser/src/main/resources/sql/supported/dml/select-special-function.xml
 
b/test/it/parser/src/main/resources/sql/supported/dml/select-special-function.xml
index b51d53dbc61..0b6af81fafc 100644
--- 
a/test/it/parser/src/main/resources/sql/supported/dml/select-special-function.xml
+++ 
b/test/it/parser/src/main/resources/sql/supported/dml/select-special-function.xml
@@ -142,4 +142,8 @@
     <sql-case id="select_floor" value="SELECT FLOOR(1.23)" db-types="MySQL" />
     <sql-case id="select_format" value="SELECT FORMAT(12332.123456, 4)" 
db-types="MySQL" />
     <sql-case id="select_format_bytes" value="SELECT FORMAT_BYTES(512)" 
db-types="MySQL" />
+    <sql-case id="select_json_parse" value="SELECT 
JSON_PARSE('{&quot;k1&quot;:&quot;v31&quot;,&quot;k2&quot;:300}')" 
db-types="Doris" />
+    <sql-case id="select_json_parse_error_to_null" value="SELECT 
JSON_PARSE('invalid json')" db-types="Doris" />
+    <sql-case id="select_json_parse_error_to_value" value="SELECT 
JSON_PARSE('invalid json', '{}')" db-types="Doris" />
+
 </sql-cases>
diff --git a/test/it/parser/src/main/resources/sql/supported/dml/select.xml 
b/test/it/parser/src/main/resources/sql/supported/dml/select.xml
index 3ebfc5116d5..0dd5214dcc6 100644
--- a/test/it/parser/src/main/resources/sql/supported/dml/select.xml
+++ b/test/it/parser/src/main/resources/sql/supported/dml/select.xml
@@ -65,7 +65,7 @@
     <sql-case id="select_count_like_concat" value="SELECT count(0) AS 
orders_count FROM t_order o WHERE o.status LIKE CONCAT('%%', ?, '%%') AND 
o.user_id IN (?, ?) AND o.order_id BETWEEN ? AND ?" 
db-types="MySQL,SQLServer,Oracle,SQL92" />
     <!--TODO combine into select_count_like_concat-->
     <sql-case id="select_count_like_concat_postgres" value="SELECT count(0) AS 
orders_count FROM t_order o WHERE o.status LIKE CONCAT('%%', ?, '%%') AND 
o.user_id IN (?, ?) AND o.order_id BETWEEN ? AND ?" 
db-types="PostgreSQL,openGauss" />
-    <sql-case id="select_like_with_single_quotes" value="select id from admin 
where fullname like 'a%'" db-types="MySQL" />
+    <sql-case id="select_like_with_single_quotes" value="select id from admin 
where fullname like 'a%'" db-types="MySQL,Doris" />
     <sql-case id="select_count_tilde_concat" value="SELECT count(0) as 
orders_count FROM t_order o WHERE o.status ~~ CONCAT('%%', ?, '%%') AND 
o.user_id IN (?, ?) AND o.order_id BETWEEN ? AND ?" 
db-types="PostgreSQL,openGauss" />
     <sql-case id="select_sharding_route_with_binding_tables" value="SELECT i.* 
FROM t_order o JOIN t_order_item i ON o.user_id = i.user_id AND o.order_id = 
i.order_id WHERE o.user_id IN (?, ?) AND o.order_id BETWEEN ? AND ? ORDER BY 
i.item_id" />
     <sql-case id="select_full_route_with_binding_tables" value="SELECT i.* 
FROM t_order o JOIN t_order_item i ON o.user_id = i.user_id AND o.order_id = 
i.order_id ORDER BY i.item_id" />

Reply via email to