Skip to content

Commit

Permalink
Support parsing Doris sql #31510 (#32184)
Browse files Browse the repository at this point in the history
  • Loading branch information
AbnerHuang2 authored Jul 19, 2024
1 parent 372efb8 commit 810aff0
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down

0 comments on commit 810aff0

Please sign in to comment.