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 eebb9788f3f Fix OpenGauss Group BY and Having parse (#28216)
eebb9788f3f is described below
commit eebb9788f3f885c25b109c68ee02a5dbf3c090ee
Author: Zichao <[email protected]>
AuthorDate: Tue Aug 22 18:21:09 2023 +1200
Fix OpenGauss Group BY and Having parse (#28216)
---
.../main/antlr4/imports/opengauss/DMLStatement.g4 | 5 +----
.../parser/src/main/resources/case/dml/select.xml | 25 ++++++++++++++++++++++
.../main/resources/sql/supported/dml/select.xml | 1 +
3 files changed, 27 insertions(+), 4 deletions(-)
diff --git
a/parser/sql/dialect/opengauss/src/main/antlr4/imports/opengauss/DMLStatement.g4
b/parser/sql/dialect/opengauss/src/main/antlr4/imports/opengauss/DMLStatement.g4
index 9440b79816c..c994e6be73f 100644
---
a/parser/sql/dialect/opengauss/src/main/antlr4/imports/opengauss/DMLStatement.g4
+++
b/parser/sql/dialect/opengauss/src/main/antlr4/imports/opengauss/DMLStatement.g4
@@ -108,10 +108,7 @@ selectWithParens
;
selectNoParens
- : selectClauseN
- | selectClauseN sortClause
- | selectClauseN sortClause? forLockingClause selectLimit?
- | selectClauseN sortClause? selectLimit forLockingClause?
+ : selectClauseN sortClause? (forLockingClause selectLimit? | selectLimit
forLockingClause?)?
| withClause selectClauseN
| withClause selectClauseN sortClause
| withClause selectClauseN sortClause? forLockingClause selectLimit?
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 6686e598342..d1ecc60b23f 100644
--- a/test/it/parser/src/main/resources/case/dml/select.xml
+++ b/test/it/parser/src/main/resources/case/dml/select.xml
@@ -6800,4 +6800,29 @@
</join-table>
</from>
</select>
+
+ <select sql-case-id="select_with_group_by_and_having">
+ <projections start-index="7" stop-index="14">
+ <column-projection name="cfg_name" start-index="7" stop-index="14"
/>
+ </projections>
+ <from>
+ <simple-table name="bmsql_config" start-index="21" stop-index="32"
/>
+ </from>
+ <group-by>
+ <column-item start-index="43" stop-index="50" name="cfg_name" />
+ </group-by>
+ <having start-index="52" stop-index="70">
+ <expr>
+ <binary-operation-expression start-index="59" stop-index="70">
+ <left>
+ <column name="cfg_name" start-index="59"
stop-index="66" />
+ </left>
+ <operator>=</operator>
+ <right>
+ <literal-expression start-index="68" stop-index="70"
value="1" />
+ </right>
+ </binary-operation-expression>
+ </expr>
+ </having>
+ </select>
</sql-parser-test-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 512d6e7e07d..406b5556367 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
@@ -206,4 +206,5 @@
<sql-case id="select_with_more_xml_functions" value="SELECT
XMLCOMMENT('OrderAnalysisComp imported, reconfigured, disassembled'),
XMLCONCAT(XMLELEMENT('First', e.first_name), XMLELEMENT('Last', e.last_name))
AS 'Result', XMLPATCH(XMLTYPE('xml')), XMLDIFF(XMLTYPE('xml'),XMLTYPE('xml2')),
XMLELEMENT('Emp', XMLATTRIBUTES(e.employee_id, e.last_name)),
XMLSEQUENCE(EXTRACT(warehouse_spec, '/Warehouse/*')) FROM DUAL"
db-types="Oracle" />
<sql-case id="select_with_nested_object" value="SELECT
o.item.line_item_id, o.item.quantity FROM short_orders o;" db-types="Oracle" />
<sql-case id="select_with_collection_table" value="SELECT VALUE(p) FROM
warehouses w, TABLE(XMLSEQUENCE(EXTRACT(warehouse_spec, '/Warehouse/*'))) p;"
db-types="Oracle" />
+ <sql-case id="select_with_group_by_and_having" value="select cfg_name from
bmsql_config group by cfg_name having cfg_name='1';" db-types="openGauss" />
</sql-cases>