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 12b8ba8f2b1 Add SQL parser test cases for Hive (#37696)
12b8ba8f2b1 is described below
commit 12b8ba8f2b18464377afd516945feee9101d0b38
Author: Liang Zhang <[email protected]>
AuthorDate: Fri Jan 9 23:10:17 2026 +0800
Add SQL parser test cases for Hive (#37696)
---
.../src/main/resources/case/dal/dal-hive.xml | 16 ++
.../src/main/resources/case/dml/insert-hive.xml | 30 ++++
.../src/main/resources/case/dml/select-hive.xml | 191 +++++++++++++++++++++
.../main/resources/sql/supported/dal/dal-hive.xml | 4 +
.../resources/sql/supported/dml/insert-hive.xml | 2 +
.../resources/sql/supported/dml/select-hive.xml | 7 +
6 files changed, 250 insertions(+)
diff --git a/test/it/parser/src/main/resources/case/dal/dal-hive.xml
b/test/it/parser/src/main/resources/case/dal/dal-hive.xml
index f31821f02c9..357337d2909 100644
--- a/test/it/parser/src/main/resources/case/dal/dal-hive.xml
+++ b/test/it/parser/src/main/resources/case/dal/dal-hive.xml
@@ -39,4 +39,20 @@
<like pattern="t_*" start-delimiter="'" end-delimiter="'"
start-index="23" stop-index="27" />
</filter>
</show-tables>
+
+ <show-databases sql-case-id="hive_show_databases_no_filter" />
+
+ <show-tables sql-case-id="hive_show_tables_simple" />
+
+ <show-columns sql-case-id="hive_show_columns_like">
+ <table name="t_order" start-index="18" stop-index="24" />
+ <filter start-index="26" stop-index="34">
+ <like pattern="p%" start-delimiter="'" end-delimiter="'"
start-index="26" stop-index="34" />
+ </filter>
+ </show-columns>
+
+ <describe sql-case-id="hive_describe_table_column">
+ <simple-table name="t_order" start-index="9" stop-index="15" />
+ <column-wild name="id" start-index="17" stop-index="18" />
+ </describe>
</sql-parser-test-cases>
diff --git a/test/it/parser/src/main/resources/case/dml/insert-hive.xml
b/test/it/parser/src/main/resources/case/dml/insert-hive.xml
index c56bf5726e9..cb00228cdab 100644
--- a/test/it/parser/src/main/resources/case/dml/insert-hive.xml
+++ b/test/it/parser/src/main/resources/case/dml/insert-hive.xml
@@ -91,4 +91,34 @@
</select>
</insert>
+ <insert sql-case-id="hive_insert_select_columns">
+ <table name="t_target" start-index="12" stop-index="19" />
+ <columns start-index="21" stop-index="30">
+ <column name="id" start-index="22" stop-index="23" />
+ <column name="name" start-index="26" stop-index="29" />
+ </columns>
+ <select>
+ <projections start-index="39" stop-index="46">
+ <column-projection name="id" start-index="39" stop-index="40"
/>
+ <column-projection name="name" start-index="43"
stop-index="46" />
+ </projections>
+ <from>
+ <simple-table name="t_source" start-index="53" stop-index="60"
/>
+ </from>
+ </select>
+ </insert>
+
+ <insert sql-case-id="hive_insert_dynamic_partition_select">
+ <table name="t_order" start-index="18" stop-index="24" />
+ <columns start-index="0" stop-index="0" />
+ <select>
+ <projections start-index="48" stop-index="48">
+ <shorthand-projection start-index="48" stop-index="48" />
+ </projections>
+ <from>
+ <simple-table name="t_source" start-index="55" stop-index="62"
/>
+ </from>
+ </select>
+ </insert>
+
</sql-parser-test-cases>
diff --git a/test/it/parser/src/main/resources/case/dml/select-hive.xml
b/test/it/parser/src/main/resources/case/dml/select-hive.xml
index 2d62676207a..b6576163f69 100644
--- a/test/it/parser/src/main/resources/case/dml/select-hive.xml
+++ b/test/it/parser/src/main/resources/case/dml/select-hive.xml
@@ -384,4 +384,195 @@
</projections>
</select>
+ <select sql-case-id="hive_select_qualified_shorthand">
+ <projections start-index="7" stop-index="19">
+ <shorthand-projection start-index="7" stop-index="19">
+ <owner name="t_order" start-index="11" stop-index="17">
+ <owner name="db1" start-index="7" stop-index="9" />
+ </owner>
+ </shorthand-projection>
+ </projections>
+ <from>
+ <simple-table name="t_order" start-index="26" stop-index="36">
+ <owner name="db1" start-index="26" stop-index="28" />
+ </simple-table>
+ </from>
+ </select>
+
+ <select sql-case-id="hive_select_xor">
+ <projections start-index="7" stop-index="7">
+ <shorthand-projection start-index="7" stop-index="7" />
+ </projections>
+ <from>
+ <simple-table name="t_logic" start-index="14" stop-index="20" />
+ </from>
+ <where start-index="22" stop-index="34">
+ <expr>
+ <binary-operation-expression start-index="28" stop-index="34">
+ <left>
+ <column name="a" start-index="28" stop-index="28" />
+ </left>
+ <operator>XOR</operator>
+ <right>
+ <column name="b" start-index="34" stop-index="34" />
+ </right>
+ </binary-operation-expression>
+ </expr>
+ </where>
+ </select>
+
+ <select sql-case-id="hive_select_in_list">
+ <projections start-index="7" stop-index="7">
+ <shorthand-projection start-index="7" stop-index="7" />
+ </projections>
+ <from>
+ <simple-table name="t_pred" start-index="14" stop-index="19" />
+ </from>
+ <where start-index="21" stop-index="38">
+ <expr>
+ <in-expression start-index="27" stop-index="38">
+ <left>
+ <column name="col" start-index="27" stop-index="29" />
+ </left>
+ <right>
+ <list-expression start-index="34" stop-index="38">
+ <items>
+ <literal-expression value="1" start-index="35"
stop-index="35" />
+ </items>
+ <items>
+ <literal-expression value="2" start-index="37"
stop-index="37" />
+ </items>
+ </list-expression>
+ </right>
+ </in-expression>
+ </expr>
+ </where>
+ </select>
+
+ <select sql-case-id="hive_select_equal_all_subquery">
+ <projections start-index="7" stop-index="7">
+ <shorthand-projection start-index="7" stop-index="7" />
+ </projections>
+ <from>
+ <simple-table name="t_pred" start-index="14" stop-index="19" />
+ </from>
+ <where start-index="21" stop-index="46">
+ <expr>
+ <binary-operation-expression start-index="27" stop-index="46">
+ <left>
+ <column name="col" start-index="27" stop-index="29" />
+ </left>
+ <operator>= ALL</operator>
+ <right>
+ <subquery start-index="37" stop-index="46">
+ <select>
+ <projections start-index="45" stop-index="45">
+ <expression-projection text="2"
start-index="45" stop-index="45">
+ <expr>
+ <literal-expression value="2"
start-index="45" stop-index="45" />
+ </expr>
+ </expression-projection>
+ </projections>
+ </select>
+ </subquery>
+ </right>
+ </binary-operation-expression>
+ </expr>
+ </where>
+ </select>
+
+ <select sql-case-id="hive_select_order_limit_param">
+ <projections start-index="7" stop-index="7">
+ <shorthand-projection start-index="7" stop-index="7" />
+ </projections>
+ <from>
+ <simple-table name="t_order" start-index="14" stop-index="20" />
+ </from>
+ <order-by>
+ <index-item index="1" order-direction="ASC" start-index="31"
stop-index="31" />
+ <expression-item expression="price + 1" order-direction="DESC"
start-index="34" stop-index="42">
+ <expr>
+ <binary-operation-expression start-index="34"
stop-index="42">
+ <left>
+ <column name="price" start-index="34"
stop-index="38" />
+ </left>
+ <operator>+</operator>
+ <right>
+ <literal-expression value="1" start-index="42"
stop-index="42" />
+ </right>
+ </binary-operation-expression>
+ </expr>
+ </expression-item>
+ </order-by>
+ <limit start-index="49" stop-index="64">
+ <row-count value="1" start-index="55" stop-index="55" />
+ <offset value="1" start-index="64" stop-index="64" />
+ </limit>
+ </select>
+
+ <select sql-case-id="hive_select_case_variables">
+ <projections start-index="7" stop-index="59">
+ <expression-projection text="CASE WHEN a > 1 THEN b ELSE c END"
start-index="7" stop-index="39">
+ <expr>
+ <case-when-expression start-index="7" stop-index="39">
+ <when-exprs>
+ <binary-operation-expression start-index="17"
stop-index="21">
+ <left>
+ <column name="a" start-index="17"
stop-index="17" />
+ </left>
+ <operator>></operator>
+ <right>
+ <literal-expression value="1"
start-index="21" stop-index="21" />
+ </right>
+ </binary-operation-expression>
+ </when-exprs>
+ <then-exprs>
+ <column name="b" start-index="28" stop-index="28"
/>
+ </then-exprs>
+ <else-expr>
+ <column name="c" start-index="35" stop-index="35"
/>
+ </else-expr>
+ </case-when-expression>
+ </expr>
+ </expression-projection>
+ <expression-projection text="@var" start-index="42"
stop-index="45">
+ <expr>
+ <variable-segment start-index="42" stop-index="45"
variable="var" />
+ </expr>
+ </expression-projection>
+ <expression-projection text="@@global.var" start-index="48"
stop-index="59">
+ <expr>
+ <variable-segment text="@@global.var" start-index="48"
stop-index="59" variable="var" scope="global" />
+ </expr>
+ </expression-projection>
+ </projections>
+ <from>
+ <simple-table name="t_case" start-index="66" stop-index="71" />
+ </from>
+ </select>
+
+ <select sql-case-id="hive_select_join_using_comma">
+ <projections start-index="7" stop-index="7">
+ <shorthand-projection start-index="7" stop-index="7" />
+ </projections>
+ <from>
+ <join-table join-type="COMMA" start-index="14" stop-index="38">
+ <left>
+ <join-table join-type="INNER" start-index="14"
stop-index="34">
+ <left>
+ <simple-table name="t1" start-index="14"
stop-index="15" />
+ </left>
+ <right>
+ <simple-table name="t2" start-index="22"
stop-index="23" />
+ </right>
+ <using-columns name="id" start-index="32"
stop-index="33" />
+ </join-table>
+ </left>
+ <right>
+ <simple-table name="t3" start-index="37" stop-index="38" />
+ </right>
+ </join-table>
+ </from>
+ </select>
+
</sql-parser-test-cases>
diff --git a/test/it/parser/src/main/resources/sql/supported/dal/dal-hive.xml
b/test/it/parser/src/main/resources/sql/supported/dal/dal-hive.xml
index ff5e2e29393..70cf25776e8 100644
--- a/test/it/parser/src/main/resources/sql/supported/dal/dal-hive.xml
+++ b/test/it/parser/src/main/resources/sql/supported/dal/dal-hive.xml
@@ -21,4 +21,8 @@
<sql-case id="hive_use_default" value="USE DEFAULT" db-types="Hive" />
<sql-case id="hive_show_databases" value="SHOW DATABASES LIKE 'test*'"
db-types="Hive" />
<sql-case id="hive_show_tables" value="SHOW TABLES IN test_db 't_*'"
db-types="Hive" />
+ <sql-case id="hive_show_databases_no_filter" value="SHOW DATABASES"
db-types="Hive" />
+ <sql-case id="hive_show_tables_simple" value="SHOW TABLES" db-types="Hive"
/>
+ <sql-case id="hive_show_columns_like" value="SHOW COLUMNS FROM t_order
LIKE 'p%'" db-types="Hive" />
+ <sql-case id="hive_describe_table_column" value="DESCRIBE t_order id"
db-types="Hive" />
</sql-cases>
diff --git
a/test/it/parser/src/main/resources/sql/supported/dml/insert-hive.xml
b/test/it/parser/src/main/resources/sql/supported/dml/insert-hive.xml
index 903914ef175..be01464cb39 100644
--- a/test/it/parser/src/main/resources/sql/supported/dml/insert-hive.xml
+++ b/test/it/parser/src/main/resources/sql/supported/dml/insert-hive.xml
@@ -22,4 +22,6 @@
<sql-case id="hive_insert_overwrite_select" value="INSERT OVERWRITE TABLE
t_order SELECT * FROM t_source" db-types="Hive" />
<sql-case id="hive_insert_partition" value="INSERT INTO TABLE t_order
PARTITION (ds='2020') VALUES (1, 'a')" db-types="Hive" />
<sql-case id="hive_from_insert" value="FROM t_source INSERT OVERWRITE
TABLE t_target SELECT *" db-types="Hive" />
+ <sql-case id="hive_insert_select_columns" value="INSERT INTO t_target (id,
name) SELECT id, name FROM t_source" db-types="Hive" />
+ <sql-case id="hive_insert_dynamic_partition_select" value="INSERT INTO
TABLE t_order PARTITION (ds) SELECT * FROM t_source" db-types="Hive" />
</sql-cases>
diff --git
a/test/it/parser/src/main/resources/sql/supported/dml/select-hive.xml
b/test/it/parser/src/main/resources/sql/supported/dml/select-hive.xml
index aaeb51b0176..d692e35e73d 100644
--- a/test/it/parser/src/main/resources/sql/supported/dml/select-hive.xml
+++ b/test/it/parser/src/main/resources/sql/supported/dml/select-hive.xml
@@ -36,4 +36,11 @@
<sql-case id="hive_select_substring" value="SELECT SUBSTRING('abc', 1, 2)"
db-types="Hive" />
<sql-case id="hive_select_trim" value="SELECT TRIM(BOTH ' ' FROM ' a ')"
db-types="Hive" />
<sql-case id="hive_select_extract" value="SELECT EXTRACT(YEAR FROM
'2023-01-01')" db-types="Hive" />
+ <sql-case id="hive_select_qualified_shorthand" value="SELECT db1.t_order.*
FROM db1.t_order" db-types="Hive" />
+ <sql-case id="hive_select_xor" value="SELECT * FROM t_logic WHERE a XOR b"
db-types="Hive" />
+ <sql-case id="hive_select_in_list" value="SELECT * FROM t_pred WHERE col
IN (1,2)" db-types="Hive" />
+ <sql-case id="hive_select_equal_all_subquery" value="SELECT * FROM t_pred
WHERE col = ALL (SELECT 2)" db-types="Hive" />
+ <sql-case id="hive_select_order_limit_param" value="SELECT * FROM t_order
ORDER BY 1, price + 1 DESC LIMIT 1 OFFSET 1" db-types="Hive" />
+ <sql-case id="hive_select_case_variables" value="SELECT CASE WHEN a > 1
THEN b ELSE c END, @var, @@global.var FROM t_case" db-types="Hive" />
+ <sql-case id="hive_select_join_using_comma" value="SELECT * FROM t1 JOIN
t2 USING (id), t3" db-types="Hive" />
</sql-cases>