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 a33b154d859 Add SQL parser test cases for SQL92 (#37732)
a33b154d859 is described below
commit a33b154d859f9694674308ac14c2ff9a6582e96d
Author: Liang Zhang <[email protected]>
AuthorDate: Tue Jan 13 20:38:20 2026 +0800
Add SQL parser test cases for SQL92 (#37732)
* Add SQL parser test cases for SQL92
* Add SQL parser test cases for SQL92
---
.../core/util/PipelineDistributedBarrier.java | 6 +-
.../src/main/resources/case/ddl/create-table.xml | 25 ++++++
.../parser/src/main/resources/case/dml/insert.xml | 14 ++++
.../src/main/resources/case/dml/select-join.xml | 31 +++++++
.../parser/src/main/resources/case/dml/select.xml | 95 ++++++++++++++++++++++
.../resources/sql/supported/ddl/create-table.xml | 3 +
.../main/resources/sql/supported/dml/insert.xml | 1 +
.../main/resources/sql/supported/dml/select.xml | 7 ++
8 files changed, 179 insertions(+), 3 deletions(-)
diff --git
a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/util/PipelineDistributedBarrier.java
b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/util/PipelineDistributedBarrier.java
index 9339412584b..0dee2ee0782 100644
---
a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/util/PipelineDistributedBarrier.java
+++
b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/util/PipelineDistributedBarrier.java
@@ -128,10 +128,10 @@ public final class PipelineDistributedBarrier {
}
try {
boolean result = holder.awaitLatchReleasing(timeout, timeUnit);
- if (!result) {
- log.warn("Await timeout, barrier path: {}, timeout: {}, time
unit: {}", barrierPath, timeout, timeUnit);
- } else {
+ if (result) {
log.info("Await success, barrier path: {}", barrierPath);
+ } else {
+ log.warn("Await timeout, barrier path: {}, timeout: {}, time
unit: {}", barrierPath, timeout, timeUnit);
}
return result;
} catch (final InterruptedException ignored) {
diff --git a/test/it/parser/src/main/resources/case/ddl/create-table.xml
b/test/it/parser/src/main/resources/case/ddl/create-table.xml
index c8c8d562d23..2614d1f6047 100644
--- a/test/it/parser/src/main/resources/case/ddl/create-table.xml
+++ b/test/it/parser/src/main/resources/case/ddl/create-table.xml
@@ -596,6 +596,31 @@
</column-definition>
<constraint-definition start-index="73" stop-index="119" />
</create-table>
+
+ <create-table sql-case-id="create_table_decimal_scale_sql92">
+ <table name="t_decimal" start-index="13" stop-index="21" />
+ <column-definition type="DECIMAL" start-index="24" stop-index="43">
+ <column name="amount" />
+ </column-definition>
+ </create-table>
+
+ <create-table sql-case-id="create_table_named_pk_sql92">
+ <table name="t_pk" start-index="13" stop-index="16" />
+ <column-definition type="INT" start-index="19" stop-index="24">
+ <column name="id" />
+ </column-definition>
+ <constraint-definition constraint-name="pk_t_pk" start-index="27"
stop-index="61">
+ <primary-key-column name="id" start-index="59" stop-index="60" />
+ </constraint-definition>
+ </create-table>
+
+ <create-table sql-case-id="create_table_check_constraint_sql92">
+ <table name="t_chk" start-index="13" stop-index="17" />
+ <column-definition type="INT" start-index="20" stop-index="29">
+ <column name="status" />
+ </column-definition>
+ <constraint-definition start-index="32" stop-index="70" />
+ </create-table>
<create-table sql-case-id="create_table_with_inline_constraints">
<table name="t_order" start-index="13" stop-index="19" />
diff --git a/test/it/parser/src/main/resources/case/dml/insert.xml
b/test/it/parser/src/main/resources/case/dml/insert.xml
index 2d8fb685f24..9979e4e71e9 100644
--- a/test/it/parser/src/main/resources/case/dml/insert.xml
+++ b/test/it/parser/src/main/resources/case/dml/insert.xml
@@ -5581,4 +5581,18 @@
</value>
</values>
</insert>
+
+ <insert sql-case-id="insert_with_default_sql92">
+ <table name="t_order" start-index="12" stop-index="18" />
+ <columns start-index="19" stop-index="26">
+ <column name="status" start-index="20" stop-index="25" />
+ </columns>
+ <values>
+ <value>
+ <assignment-value>
+ <common-expression text="DEFAULT" start-index="36"
stop-index="42" />
+ </assignment-value>
+ </value>
+ </values>
+ </insert>
</sql-parser-test-cases>
diff --git a/test/it/parser/src/main/resources/case/dml/select-join.xml
b/test/it/parser/src/main/resources/case/dml/select-join.xml
index 34d7590eccf..9f6973a59e2 100644
--- a/test/it/parser/src/main/resources/case/dml/select-join.xml
+++ b/test/it/parser/src/main/resources/case/dml/select-join.xml
@@ -185,6 +185,37 @@
</where>
</select>
+ <select sql-case-id="select_inner_join_sql92">
+ <from>
+ <join-table join-type="INNER">
+ <left>
+ <simple-table name="t_order" start-index="14"
stop-index="20" />
+ </left>
+ <right>
+ <simple-table name="t_order_item" start-index="33"
stop-index="44" />
+ </right>
+ <on-condition>
+ <binary-operation-expression start-index="49"
stop-index="88">
+ <left>
+ <column name="order_id" start-index="49"
stop-index="64">
+ <owner name="t_order" start-index="49"
stop-index="55" />
+ </column>
+ </left>
+ <operator>=</operator>
+ <right>
+ <column name="order_id" start-index="68"
stop-index="88">
+ <owner name="t_order_item" start-index="68"
stop-index="79" />
+ </column>
+ </right>
+ </binary-operation-expression>
+ </on-condition>
+ </join-table>
+ </from>
+ <projections start-index="7" stop-index="7">
+ <shorthand-projection start-index="7" stop-index="7" />
+ </projections>
+ </select>
+
<select sql-case-id="select_left_outer_join_related_with_alias">
<from>
<join-table join-type="LEFT">
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 d709d18f84b..030019b0d26 100644
--- a/test/it/parser/src/main/resources/case/dml/select.xml
+++ b/test/it/parser/src/main/resources/case/dml/select.xml
@@ -12895,6 +12895,101 @@
</from>
</select>
+ <select sql-case-id="select_null_literal_sql92">
+ <projections start-index="7" stop-index="10">
+ <expression-projection text="null" start-index="7" stop-index="10">
+ <expr>
+ <literal-expression value="null" start-index="7"
stop-index="10" />
+ </expr>
+ </expression-projection>
+ </projections>
+ <from>
+ <simple-table name="t_order" start-index="17" stop-index="23" />
+ </from>
+ </select>
+
+ <select sql-case-id="select_where_is_not_null_sql92">
+ <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="45">
+ <expr>
+ <binary-operation-expression start-index="28" stop-index="45">
+ <left>
+ <column name="status" start-index="28" stop-index="33"
/>
+ </left>
+ <operator>IS</operator>
+ <right>
+ <literal-expression value="NOT NULL" start-index="38"
stop-index="45" />
+ </right>
+ </binary-operation-expression>
+ </expr>
+ </where>
+ </select>
+
+ <select sql-case-id="select_compare_subquery_sql92">
+ <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>
+ <where start-index="22" stop-index="48">
+ <expr>
+ <binary-operation-expression start-index="28" stop-index="48">
+ <left>
+ <column name="order_id" start-index="28"
stop-index="35" />
+ </left>
+ <operator>=</operator>
+ <right>
+ <subquery start-index="39" stop-index="48">
+ <select>
+ <projections start-index="47" stop-index="47">
+ <expression-projection text="1"
start-index="47" stop-index="47">
+ <expr>
+ <literal-expression value="1"
start-index="47" stop-index="47" />
+ </expr>
+ </expression-projection>
+ </projections>
+ </select>
+ </subquery>
+ </right>
+ </binary-operation-expression>
+ </expr>
+ </where>
+ </select>
+
+ <select sql-case-id="select_interval_expression_sql92">
+ <projections start-index="7" stop-index="20">
+ <expression-projection text="INTERVAL1DAY" start-index="7"
stop-index="20">
+ </expression-projection>
+ </projections>
+ </select>
+
+ <select sql-case-id="select_position_function_sql92">
+ <projections start-index="7" stop-index="28">
+ <expression-projection text="POSITION('a' IN 'aaa')"
start-index="7" stop-index="28">
+ <expr>
+ <function start-index="7" stop-index="28"
text="POSITION('a' IN 'aaa')" function-name="POSITION">
+ </function>
+ </expr>
+ </expression-projection>
+ </projections>
+ </select>
+
+ <select sql-case-id="select_without_from_sql92">
+ <projections start-index="7" stop-index="7">
+ <expression-projection text="1" start-index="7" stop-index="7">
+ <expr>
+ <literal-expression value="1" start-index="7"
stop-index="7" />
+ </expr>
+ </expression-projection>
+ </projections>
+ </select>
+
<select sql-case-id="select_subquery_with_with_firebird">
<projections start-index="7" stop-index="7">
<shorthand-projection start-index="7" stop-index="7" />
diff --git
a/test/it/parser/src/main/resources/sql/supported/ddl/create-table.xml
b/test/it/parser/src/main/resources/sql/supported/ddl/create-table.xml
index 3b45824e766..f05367f91ec 100644
--- a/test/it/parser/src/main/resources/sql/supported/ddl/create-table.xml
+++ b/test/it/parser/src/main/resources/sql/supported/ddl/create-table.xml
@@ -68,6 +68,9 @@
<sql-case id="create_table_with_inline_foreign_key" value="CREATE TABLE
t_order_item (item_id INT, order_id INT REFERENCES t_order (order_id) ON UPDATE
CASCADE ON DELETE CASCADE, user_id INT, status VARCHAR(10), column1
VARCHAR(10), column2 VARCHAR(10), column3 VARCHAR(10))" db-types="MySQL" />
<sql-case id="create_table_with_inline_foreign_key_sql92" value="CREATE
TABLE t_order_item (item_id INT, order_id INT REFERENCES t_order (order_id) ON
UPDATE CASCADE ON DELETE CASCADE, user_id INT, status VARCHAR(10), column1
VARCHAR(10), column2 VARCHAR(10), column3 VARCHAR(10))" db-types="SQL92" />
<sql-case id="create_table_constraint_sql92" value="CREATE TABLE
t_constraint (order_id INT PRIMARY KEY, status VARCHAR(10), CONSTRAINT
ck_status CHECK (status IS NOT NULL))" db-types="SQL92" />
+ <sql-case id="create_table_decimal_scale_sql92" value="CREATE TABLE
t_decimal (amount DECIMAL(10,2))" db-types="SQL92" />
+ <sql-case id="create_table_named_pk_sql92" value="CREATE TABLE t_pk (id
INT, CONSTRAINT pk_t_pk PRIMARY KEY (id))" db-types="SQL92" />
+ <sql-case id="create_table_check_constraint_sql92" value="CREATE TABLE
t_chk (status INT, CONSTRAINT ck_status CHECK (status > 0))"
db-types="SQL92" />
<sql-case id="create_table_with_inline_constraints" value="CREATE TABLE
t_order (order_id INT PRIMARY KEY UNIQUE, user_id INT, status VARCHAR(10),
column1 VARCHAR(10), column2 VARCHAR(10), column3 VARCHAR(10))"
db-types="MySQL,Oracle,PostgreSQL,openGauss" />
<sql-case id="create_table_with_out_of_line_primary_key" value="CREATE
TABLE t_order (order_id INT, user_id INT, status VARCHAR(10), column1
VARCHAR(10), column2 VARCHAR(10), column3 VARCHAR(10), CONSTRAINT pk_order_id
PRIMARY KEY (order_id))" />
<sql-case id="create_table_with_out_of_line_composite_primary_key"
value="CREATE TABLE t_order (order_id INT, user_id INT, status VARCHAR(10),
column1 VARCHAR(10), column2 VARCHAR(10), column3 VARCHAR(10), CONSTRAINT
pk_order_id PRIMARY KEY (order_id, user_id, status))" />
diff --git a/test/it/parser/src/main/resources/sql/supported/dml/insert.xml
b/test/it/parser/src/main/resources/sql/supported/dml/insert.xml
index 5228c46e804..9f35038b22f 100644
--- a/test/it/parser/src/main/resources/sql/supported/dml/insert.xml
+++ b/test/it/parser/src/main/resources/sql/supported/dml/insert.xml
@@ -202,4 +202,5 @@
<sql-case id="insert_into_with_null" value="INSERT INTO TABLE user_info
VALUES (301, NULL, 'New York'), (302, 'Charlie', NULL);" db-types="Hive" />
<sql-case id="insert_with_columns_sql92" value="INSERT INTO
t_order(order_id, status) VALUES (1, 'ok')" db-types="SQL92" />
<sql-case id="insert_without_columns_sql92" value="INSERT INTO t_order
VALUES (1, 'ok')" db-types="SQL92" />
+ <sql-case id="insert_with_default_sql92" value="INSERT INTO
t_order(status) VALUES (DEFAULT)" db-types="SQL92" />
</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 5a74a2d99a9..c839de5b39e 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
@@ -426,6 +426,8 @@
<sql-case id="select_not_expression_sql92" value="SELECT NOT (1=1) FROM
t_order" db-types="SQL92" />
<sql-case id="select_where_is_true_sql92" value="SELECT * FROM t_order
WHERE active IS TRUE" db-types="SQL92" />
<sql-case id="select_where_is_false_sql92" value="SELECT * FROM t_order
WHERE active IS FALSE" db-types="SQL92" />
+ <sql-case id="select_where_is_not_null_sql92" value="SELECT * FROM t_order
WHERE status IS NOT NULL" db-types="SQL92" />
+ <sql-case id="select_compare_subquery_sql92" value="SELECT * FROM t_order
WHERE order_id = (SELECT 1)" db-types="SQL92" />
<sql-case id="select_distinct_simple_sql92" value="SELECT DISTINCT user_id
FROM t_order" db-types="SQL92" />
<sql-case id="select_distinct_with_count_sql92" value="SELECT
COUNT(DISTINCT order_id) c FROM t_order WHERE order_id < 1100"
db-types="SQL92" />
<sql-case id="select_having_sql92" value="SELECT user_id, COUNT(*) AS cnt
FROM t_order GROUP BY user_id HAVING COUNT(*) > 1" db-types="SQL92" />
@@ -437,6 +439,11 @@
<sql-case id="select_not_in_subquery_sql92" value="SELECT order_id FROM
t_order WHERE order_id NOT IN (SELECT 1)" db-types="SQL92" />
<sql-case id="select_not_between_sql92" value="SELECT order_id FROM
t_order WHERE order_id NOT BETWEEN 1 AND 2" db-types="SQL92" />
<sql-case id="select_addition_expr_sql92" value="SELECT order_id + 1 FROM
t_order" db-types="SQL92" />
+ <sql-case id="select_interval_expression_sql92" value="SELECT INTERVAL 1
DAY" db-types="SQL92" />
+ <sql-case id="select_position_function_sql92" value="SELECT POSITION('a'
IN 'aaa')" db-types="SQL92" />
+ <sql-case id="select_null_literal_sql92" value="SELECT NULL FROM t_order"
db-types="SQL92" />
+ <sql-case id="select_without_from_sql92" value="SELECT 1" db-types="SQL92"
/>
+ <sql-case id="select_inner_join_sql92" value="SELECT * FROM t_order INNER
JOIN t_order_item ON t_order.order_id = t_order_item.order_id" db-types="SQL92"
/>
<sql-case id="select_subquery_projection_sql92" value="SELECT (SELECT 1)
sub FROM t_order" db-types="SQL92" />
<sql-case id="select_hex_literal_sql92" value="SELECT 0x1 FROM t_order"
db-types="SQL92" />
<sql-case id="select_bit_literal_sql92" value="SELECT B'1' FROM t_order"
db-types="SQL92" />