This is an automated email from the ASF dual-hosted git repository.
zhangliang 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 492b843046e Add SQL parser test cases for MySQL (#37840)
492b843046e is described below
commit 492b843046e145599c965fc0dc4a02b70ead8129
Author: Liang Zhang <[email protected]>
AuthorDate: Sun Jan 25 22:21:21 2026 +0800
Add SQL parser test cases for MySQL (#37840)
---
.../main/resources/case/dml/select-expression.xml | 68 +++++++++++++++++
.../parser/src/main/resources/case/dml/select.xml | 88 ++++++++++++++++++++++
.../sql/supported/dml/select-expression.xml | 2 +
.../main/resources/sql/supported/dml/select.xml | 4 +
4 files changed, 162 insertions(+)
diff --git a/test/it/parser/src/main/resources/case/dml/select-expression.xml
b/test/it/parser/src/main/resources/case/dml/select-expression.xml
index a3db758ceca..7854b4e115b 100644
--- a/test/it/parser/src/main/resources/case/dml/select-expression.xml
+++ b/test/it/parser/src/main/resources/case/dml/select-expression.xml
@@ -3349,4 +3349,72 @@
</expression-projection>
</projections>
</select>
+
+ <select sql-case-id="select_where_equal_any_subquery_mysql">
+ <from start-index="14" stop-index="20">
+ <simple-table name="t_order" start-index="14" stop-index="20" />
+ </from>
+ <projections distinct-row="false" start-index="7" stop-index="7">
+ <shorthand-projection start-index="7" stop-index="7" />
+ </projections>
+ <where start-index="22" stop-index="67">
+ <expr>
+ <binary-operation-expression start-index="28" stop-index="67">
+ <left>
+ <column name="amount" start-index="28" stop-index="33"
/>
+ </left>
+ <operator>=</operator>
+ <right>
+ <quantify-subquery-expression>
+ <operator>ANY</operator>
+ <subquery start-index="41" stop-index="67">
+ <select>
+ <projections distinct-row="false"
start-index="49" stop-index="53">
+ <column-projection name="price"
start-index="49" stop-index="53" />
+ </projections>
+ <from start-index="55" stop-index="66">
+ <simple-table name="t_price"
start-index="60" stop-index="66" />
+ </from>
+ </select>
+ </subquery>
+ </quantify-subquery-expression>
+ </right>
+ </binary-operation-expression>
+ </expr>
+ </where>
+ </select>
+
+ <select sql-case-id="select_where_not_equal_all_subquery_mysql">
+ <from start-index="14" stop-index="20">
+ <simple-table name="t_order" start-index="14" stop-index="20" />
+ </from>
+ <projections distinct-row="false" start-index="7" stop-index="7">
+ <shorthand-projection start-index="7" stop-index="7" />
+ </projections>
+ <where start-index="22" stop-index="68">
+ <expr>
+ <binary-operation-expression start-index="28" stop-index="68">
+ <left>
+ <column name="amount" start-index="28" stop-index="33"
/>
+ </left>
+ <operator><></operator>
+ <right>
+ <quantify-subquery-expression>
+ <operator>ALL</operator>
+ <subquery start-index="42" stop-index="68">
+ <select>
+ <projections distinct-row="false"
start-index="50" stop-index="54">
+ <column-projection name="price"
start-index="50" stop-index="54" />
+ </projections>
+ <from start-index="56" stop-index="67">
+ <simple-table name="t_price"
start-index="61" stop-index="67" />
+ </from>
+ </select>
+ </subquery>
+ </quantify-subquery-expression>
+ </right>
+ </binary-operation-expression>
+ </expr>
+ </where>
+ </select>
</sql-parser-test-cases>
diff --git a/test/it/parser/src/main/resources/case/dml/select.xml
b/test/it/parser/src/main/resources/case/dml/select.xml
index 021f9748252..c6e32d3fbf0 100644
--- a/test/it/parser/src/main/resources/case/dml/select.xml
+++ b/test/it/parser/src/main/resources/case/dml/select.xml
@@ -12705,6 +12705,94 @@
</where>
</select>
+ <select sql-case-id="select_where_is_true_mysql">
+ <from>
+ <simple-table name="t_order" start-index="14" stop-index="20" />
+ </from>
+ <projections start-index="7" stop-index="7">
+ <shorthand-projection start-index="7" stop-index="7" />
+ </projections>
+ <where start-index="22" stop-index="41">
+ <expr>
+ <binary-operation-expression start-index="28" stop-index="41">
+ <left>
+ <column name="active" start-index="28" stop-index="33"
/>
+ </left>
+ <operator>IS</operator>
+ <right>
+ <literal-expression value="TRUE" start-index="38"
stop-index="41" />
+ </right>
+ </binary-operation-expression>
+ </expr>
+ </where>
+ </select>
+
+ <select sql-case-id="select_where_is_false_mysql">
+ <from>
+ <simple-table name="t_order" start-index="14" stop-index="20" />
+ </from>
+ <projections start-index="7" stop-index="7">
+ <shorthand-projection start-index="7" stop-index="7" />
+ </projections>
+ <where start-index="22" stop-index="42">
+ <expr>
+ <binary-operation-expression start-index="28" stop-index="42">
+ <left>
+ <column name="active" start-index="28" stop-index="33"
/>
+ </left>
+ <operator>IS</operator>
+ <right>
+ <literal-expression value="FALSE" start-index="38"
stop-index="42" />
+ </right>
+ </binary-operation-expression>
+ </expr>
+ </where>
+ </select>
+
+ <select sql-case-id="select_where_is_unknown_mysql">
+ <from>
+ <simple-table name="t_order" start-index="14" stop-index="20" />
+ </from>
+ <projections start-index="7" stop-index="7">
+ <shorthand-projection start-index="7" stop-index="7" />
+ </projections>
+ <where start-index="22" stop-index="44">
+ <expr>
+ <binary-operation-expression start-index="28" stop-index="44">
+ <left>
+ <column name="active" start-index="28" stop-index="33"
/>
+ </left>
+ <operator>IS</operator>
+ <right>
+ <literal-expression value="UNKNOWN" start-index="38"
stop-index="44" />
+ </right>
+ </binary-operation-expression>
+ </expr>
+ </where>
+ </select>
+
+ <select sql-case-id="select_null_safe_equal_mysql" parameters="1">
+ <from>
+ <simple-table name="t_order" start-index="14" stop-index="20" />
+ </from>
+ <projections start-index="7" stop-index="7">
+ <shorthand-projection start-index="7" stop-index="7" />
+ </projections>
+ <where start-index="22" stop-index="41">
+ <expr>
+ <binary-operation-expression start-index="28" stop-index="41">
+ <left>
+ <column name="order_id" start-index="28"
stop-index="35" />
+ </left>
+ <operator><=></operator>
+ <right>
+ <parameter-marker-expression parameter-index="0"
start-index="41" stop-index="41" />
+ </right>
+ </binary-operation-expression>
+ </expr>
+ </where>
+ </select>
+
<select sql-case-id="select_distinct_simple_sql92" >
<from>
<simple-table name="t_order" start-index="29" stop-index="35" />
diff --git
a/test/it/parser/src/main/resources/sql/supported/dml/select-expression.xml
b/test/it/parser/src/main/resources/sql/supported/dml/select-expression.xml
index 2746bbe4690..71bb82ea856 100644
--- a/test/it/parser/src/main/resources/sql/supported/dml/select-expression.xml
+++ b/test/it/parser/src/main/resources/sql/supported/dml/select-expression.xml
@@ -145,4 +145,6 @@
<sql-case id="select_text_inet_function" value="SELECT text(inet
'192.168.1.5') AS RESULT;" db-types="openGauss" />
<sql-case id="select_trunc_function" value="SELECT trunc(macaddr
'12:34:56:78:90:ab') AS RESULT;" db-types="openGauss" />
<sql-case id="select_with_case_when_from_sys" value="SELECT FileName =
df.name, current_file_size_MB = df.size*1.0/128, max_size = CASE df.max_size
WHEN 0 THEN 'Autogrowth is off.' WHEN -1 THEN 'Autogrowth is on.' ELSE 'Log
file grows to a maximum size of 2 TB.' END, growth_value = CASE WHEN df.growth
= 0 THEN df.growth WHEN df.growth > 0 AND df.is_percent_growth = 0 THEN
df.growth*1.0/128.0 WHEN df.growth > 0 AND df.is_percent_growth = 1 THEN
df.growth END, growth_increment_unit = C [...]
+ <sql-case id="select_where_equal_any_subquery_mysql" value="SELECT * FROM
t_order WHERE amount = ANY (SELECT price FROM t_price)" db-types="MySQL" />
+ <sql-case id="select_where_not_equal_all_subquery_mysql" value="SELECT *
FROM t_order WHERE amount <> ALL (SELECT price FROM t_price)"
db-types="MySQL" />
</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 2ebd8ba2d9b..a9d9fd8710c 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
@@ -464,4 +464,8 @@
<sql-case id="select_subquery_table_sql92" value="SELECT * FROM (SELECT 1)
t" db-types="SQL92" />
<sql-case id="select_comma_join_sql92" value="SELECT * FROM t_order o,
t_order_item i" db-types="SQL92" />
<sql-case id="select_cross_join_sql92" value="SELECT * FROM t_order CROSS
JOIN t_order_item" db-types="SQL92" />
+ <sql-case id="select_where_is_true_mysql" value="SELECT * FROM t_order
WHERE active IS TRUE" db-types="MySQL" />
+ <sql-case id="select_where_is_false_mysql" value="SELECT * FROM t_order
WHERE active IS FALSE" db-types="MySQL" />
+ <sql-case id="select_where_is_unknown_mysql" value="SELECT * FROM t_order
WHERE active IS UNKNOWN" db-types="MySQL" />
+ <sql-case id="select_null_safe_equal_mysql" value="SELECT * FROM t_order
WHERE order_id <=> ?" db-types="MySQL" case-types="PLACEHOLDER" />
</sql-cases>