You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2021/03/31 04:54:28 UTC
[shardingsphere] branch master updated: fix issue#9693 (#9885)
This is an automated email from the ASF dual-hosted git repository.
zhangyonglun 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 c9f65c5 fix issue#9693 (#9885)
c9f65c5 is described below
commit c9f65c5d74fd364ba464405bb2db4a1ff8bc5150
Author: JingShang Lu <lu...@apache.org>
AuthorDate: Wed Mar 31 12:53:52 2021 +0800
fix issue#9693 (#9885)
---
.../segment/dml/expr/AggregateExpression.java | 39 ----------------------
.../segment/dml/expr/AllColumnExpression.java | 30 -----------------
.../dml/item/AggregationProjectionSegment.java | 3 +-
.../src/main/resources/case/dml/select.xml | 6 ++++
.../main/resources/sql/supported/dml/select.xml | 1 +
5 files changed, 9 insertions(+), 70 deletions(-)
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/segment/dml/expr/AggregateExpression.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/segment/dml/expr/AggregateExpression.java
deleted file mode 100644
index f3f014c..0000000
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/segment/dml/expr/AggregateExpression.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr;
-
-import lombok.Getter;
-import lombok.Setter;
-import org.apache.shardingsphere.sql.parser.sql.common.constant.AggregationType;
-
-import java.util.List;
-
-@Setter
-@Getter
-public final class AggregateExpression implements ExpressionSegment {
-
- private int startIndex;
-
- private int stopIndex;
-
- private AggregationType methodName;
-
- private List<ExpressionSegment> args;
-
- private boolean distinct;
-}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/segment/dml/expr/AllColumnExpression.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/segment/dml/expr/AllColumnExpression.java
deleted file mode 100644
index 8d5306f..0000000
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/segment/dml/expr/AllColumnExpression.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-
-@RequiredArgsConstructor
-@Getter
-public final class AllColumnExpression implements ExpressionSegment {
-
- private int startIndex;
-
- private int stopIndex;
-}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/segment/dml/item/AggregationProjectionSegment.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/segment/dml/item/AggregationProjectionSegment.java
index 01dc55d..e91306a 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/segment/dml/item/AggregationProjectionSegment.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/segment/dml/item/AggregationProjectionSegment.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.sql.parser.sql.common.segment.dml.item;
import lombok.Getter;
import lombok.Setter;
import org.apache.shardingsphere.sql.parser.sql.common.constant.AggregationType;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.ExpressionSegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.AliasAvailable;
import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.AliasSegment;
@@ -29,7 +30,7 @@ import java.util.Optional;
* Aggregation projection segment.
*/
@Getter
-public class AggregationProjectionSegment implements ProjectionSegment, AliasAvailable {
+public class AggregationProjectionSegment implements ProjectionSegment, AliasAvailable, ExpressionSegment {
private final int startIndex;
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/case/dml/select.xml b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/case/dml/select.xml
index d27f7f2..7dd59f3 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/case/dml/select.xml
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/case/dml/select.xml
@@ -23,6 +23,12 @@
</projections>
</select>
+ <select sql-case-id="select_with_binary_operation_of_aggregation_expr" >
+ <projections start-index="7" stop-index="23">
+ <expression-projection text="count(*)+1" alias="a" start-index="8" stop-index="23" />
+ </projections>
+ </select>
+
<select sql-case-id="select_with_schema_func" >
<projections start-index="7" stop-index="26">
<expression-projection text="schema()" start-index="7" stop-index="14" />
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/sql/supported/dml/select.xml b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/sql/supported/dml/select.xml
index fbaffe4..98e184a 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/sql/supported/dml/select.xml
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/sql/supported/dml/select.xml
@@ -18,6 +18,7 @@
<sql-cases>
<sql-case id="select_constant_without_table" value="SELECT 1 as a" />
+ <sql-case id="select_with_binary_operation_of_aggregation_expr" value="SELECT (count(*)+1) as a" db-types="MySQL" />
<sql-case id="select_with_schema_func" value="SELECT schema(), database()" db-types="MySQL" />
<sql-case id="select_sqlmode_ansi_quotes" value='select "id" from "t_order" where "t_order"."id"=10' db-types="MySQL" />
<sql-case id="select_with_union" value="SELECT * from table1 union select * from table2" db-types="PostgreSQL"/>