You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by du...@apache.org on 2023/07/04 10:14:12 UTC
[shardingsphere] branch master updated: Add mysql select InExpression parse (#25535) (#26476)
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 71c24eefcd6 Add mysql select InExpression parse (#25535) (#26476)
71c24eefcd6 is described below
commit 71c24eefcd66d67aeaf81d834bd31c09bc3fba5c
Author: niu niu <zi...@aliyun.com>
AuthorDate: Tue Jul 4 18:14:04 2023 +0800
Add mysql select InExpression parse (#25535) (#26476)
---
.../visitor/statement/MySQLStatementVisitor.java | 5 +++
.../parser/src/main/resources/case/dml/select.xml | 37 ++++++++++++++++++++++
.../main/resources/sql/supported/dml/select.xml | 1 +
3 files changed, 43 insertions(+)
diff --git a/parser/sql/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/MySQLStatementVisitor.java b/parser/sql/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/MySQLStatementVisitor.java
index b0d602ae3c0..3c7ca700856 100644
--- a/parser/sql/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/MySQLStatementVisitor.java
+++ b/parser/sql/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/MySQLStatementVisitor.java
@@ -1697,6 +1697,11 @@ public abstract class MySQLStatementVisitor extends MySQLStatementBaseVisitor<AS
result.setAlias(alias);
return result;
}
+ if (projection instanceof InExpression) {
+ ExpressionProjectionSegment result = new ExpressionProjectionSegment(ctx.start.getStartIndex(), ctx.stop.getStopIndex(), getOriginalText(ctx.expr()), (InExpression) projection);
+ result.setAlias(alias);
+ return result;
+ }
LiteralExpressionSegment column = (LiteralExpressionSegment) projection;
ExpressionProjectionSegment result = null == alias
? new ExpressionProjectionSegment(column.getStartIndex(), column.getStopIndex(), String.valueOf(column.getLiterals()), column)
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 42e0aad83c4..5fad5747135 100644
--- a/test/it/parser/src/main/resources/case/dml/select.xml
+++ b/test/it/parser/src/main/resources/case/dml/select.xml
@@ -17,6 +17,43 @@
-->
<sql-parser-test-cases>
+ <select sql-case-id="select_with_exist_in">
+ <projections start-index="7" stop-index="93">
+ <expression-projection text="+0 IN(0b111111111111111111111111111111111111111111111111111,rpad(1.0,2048,1),32767.1)" start-index="7" stop-index="93">
+ <expr>
+ <in-expression start-index="8" stop-index="92">
+ <left start-index="8" stop-index="9">
+ <literal-expression start-index="8" stop-index="9" value="0" />
+ </left>
+ <right start-index="13" stop-index="92">
+ <list-expression start-index="13" stop-index="92">
+ <items>
+ <common-expression start-index="14" stop-index="66" text="0b111111111111111111111111111111111111111111111111111" />
+ </items>
+ <items>
+ <function start-index="68" stop-index="83" text="rpad(1.0,2048,1)" function-name="rpad">
+ <parameter>
+ <literal-expression start-index="73" stop-index="75" value="1.0" />
+ </parameter>
+ <parameter>
+ <literal-expression start-index="77" stop-index="80" value="2048" />
+ </parameter>
+ <parameter>
+ <literal-expression start-index="82" stop-index="82" value="1" />
+ </parameter>
+ </function>
+ </items>
+ <items>
+ <literal-expression start-index="85" stop-index="91" value="32767.1" />
+ </items>
+ </list-expression>
+ </right>
+ </in-expression>
+ </expr>
+ </expression-projection>
+ </projections>
+ </select>
+
<select sql-case-id="select_constant_without_table" >
<projections start-index="7" stop-index="12">
<expression-projection text="1" alias="a" start-index="7" stop-index="12">
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 dee2129d916..ed2df4974c6 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
@@ -17,6 +17,7 @@
-->
<sql-cases>
+ <sql-case id="select_with_exist_in" value="SELECT (+0 IN(0b111111111111111111111111111111111111111111111111111,rpad(1.0,2048,1),32767.1))" db-types="MySQL" />
<sql-case id="select_constant_without_table" value="SELECT 1 as a" db-types="MySQL, PostgreSQL,openGauss, SQLServer" />
<sql-case id="select_with_operator_ilike" value="SELECT id from t_order where name !~ '^pg_toast'" db-types="PostgreSQL,openGauss" />
<sql-case id="select_with_binary_operation_of_aggregation_expr" value="SELECT (count(*)+1) as a" db-types="MySQL" />