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 9c86e527e18 Support oracle CONNECT_BY_ROOT clause parsing (#27415)
9c86e527e18 is described below
commit 9c86e527e187b11d4bc75f5f8d925ad427ae4e1c
Author: ZhangCheng <[email protected]>
AuthorDate: Mon Jul 24 15:28:46 2023 +0800
Support oracle CONNECT_BY_ROOT clause parsing (#27415)
---
.../sql/dialect/oracle/src/main/antlr4/imports/oracle/BaseRule.g4 | 1 +
test/it/parser/src/main/resources/case/dml/select.xml | 8 ++++++++
test/it/parser/src/main/resources/sql/supported/dml/select.xml | 1 +
3 files changed, 10 insertions(+)
diff --git
a/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/BaseRule.g4
b/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/BaseRule.g4
index b7fa414e120..e871ec72cdd 100644
--- a/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/BaseRule.g4
+++ b/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/BaseRule.g4
@@ -630,6 +630,7 @@ notOperator
booleanPrimary
: booleanPrimary IS NOT? (TRUE | FALSE | UNKNOWN | NULL)
| PRIOR predicate
+ | CONNECT_BY_ROOT predicate
| booleanPrimary SAFE_EQ_ predicate
| booleanPrimary comparisonOperator predicate
| booleanPrimary comparisonOperator (ALL | ANY) subquery
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 1fabc68af68..e470975292f 100644
--- a/test/it/parser/src/main/resources/case/dml/select.xml
+++ b/test/it/parser/src/main/resources/case/dml/select.xml
@@ -5675,4 +5675,12 @@
<simple-table name="TEST" start-index="78" stop-index="81"
literal-start-index="78" literal-stop-index="81"/>
</from>
</select>
+ <select sql-case-id="select_with_connect_by_root">
+ <projections start-index="7" stop-index="41" literal-start-index="7"
literal-stop-index="41">
+ <column-projection alias="Manager" name="last_name"
start-index="23" stop-index="41" literal-start-index="23"
literal-stop-index="41"/>
+ </projections>
+ <from>
+ <simple-table name="employees" start-index="48" stop-index="56"
literal-start-index="48" literal-stop-index="56"/>
+ </from>
+ </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 c9d4a38a540..1d336a068cf 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
@@ -190,4 +190,5 @@
<sql-case id="select_with_xml_is_schema_valid_function" value="SELECT
x.xmlcol.isSchemaValid('http://www.example.com/schemas/ipo.xsd','purchaseOrder')
FROM po_tab x;" db-types="Oracle" />
<sql-case id="select_with_last_value_function" value="SELECT
LAST_VALUE(AGE IGNORE NULLS) OVER (PARTITION BY AGE ORDER BY AGE) from TEST;"
db-types="Oracle" />
<sql-case id="select_with_lead_and_lag_function" value="SELECT hire_date,
LAG(hire_date, 1) OVER (ORDER BY hire_date) AS LAG1, LEAD(hire_date, 1) OVER
(ORDER BY hire_date) AS LEAD1 FROM employees WHERE department_id = 30 ORDER BY
hire_date;" db-types="Oracle" />
+ <sql-case id="select_with_connect_by_root" value="SELECT CONNECT_BY_ROOT
last_name 'Manager' FROM employees CONNECT BY PRIOR employee_id = manager_id"
db-types="Oracle" />
</sql-cases>