This is an automated email from the ASF dual-hosted git repository.
terrymanu 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 0ee15dd7b8b Support parsing Oracle CREATE INDEX sql (#39292)
0ee15dd7b8b is described below
commit 0ee15dd7b8b71afe0ca9a19a597a0761cac1d86d
Author: Claire <[email protected]>
AuthorDate: Sat Aug 1 02:30:51 2026 +0800
Support parsing Oracle CREATE INDEX sql (#39292)
* support create index
* release notes
---
RELEASE-NOTES.md | 1 +
.../oracle/src/main/antlr4/imports/oracle/DDLStatement.g4 | 10 +++++++++-
.../visitor/statement/type/OracleDDLStatementVisitor.java | 7 ++++++-
test/it/parser/src/main/resources/case/ddl/create-index.xml | 8 ++++++++
.../src/main/resources/sql/supported/ddl/create-index.xml | 1 +
5 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md
index 7b5bc17a918..3de998dc82b 100644
--- a/RELEASE-NOTES.md
+++ b/RELEASE-NOTES.md
@@ -76,6 +76,7 @@
1. SQL Parser: Support SQLServer table variable declaration parse -
[#38904](https://github.com/apache/shardingsphere/pull/38904)
1. SQL Parser: Support Oracle procedure parser and binder -
[#39231](https://github.com/apache/shardingsphere/pull/39231)
1. SQL Parser: Support Oracle database object DDL parsing -
[#39286](https://github.com/apache/shardingsphere/pull/39286)
+1. SQL Parser: Support parsing Oracle CREATE INDEX sql -
[#39292](https://github.com/apache/shardingsphere/pull/39292)
1. SQL Parser: Support function table alias column parsing for PostgreSQL and
openGauss - [#39268](https://github.com/apache/shardingsphere/pull/39268)
1. SQL Binder: Support select order by index bind metadata -
[#38386](https://github.com/apache/shardingsphere/pull/38386)
1. SQL Binder: Support SQL bind when with temp table name is same with
physical table - [#38411](https://github.com/apache/shardingsphere/pull/38411)
diff --git
a/parser/sql/engine/dialect/oracle/src/main/antlr4/imports/oracle/DDLStatement.g4
b/parser/sql/engine/dialect/oracle/src/main/antlr4/imports/oracle/DDLStatement.g4
index 12bdf657689..526c9ce2cca 100644
---
a/parser/sql/engine/dialect/oracle/src/main/antlr4/imports/oracle/DDLStatement.g4
+++
b/parser/sql/engine/dialect/oracle/src/main/antlr4/imports/oracle/DDLStatement.g4
@@ -486,7 +486,15 @@ partitionedTable
;
domainIndexClause
- : indexTypeName localDomainIndexClause? parallelClause? (PARAMETERS LP_
SQ_ odciParameters SQ_ RP_)?
+ : indexTypeName localDomainIndexClause? parallelClause?
domainIndexFilterByClause? domainIndexOrderByClause? (PARAMETERS LP_ STRING_
RP_)?
+ ;
+
+domainIndexFilterByClause
+ : FILTER BY columnName (COMMA_ columnName)*
+ ;
+
+domainIndexOrderByClause
+ : ORDER BY columnName (ASC | DESC)? (COMMA_ columnName (ASC | DESC)?)*
;
localDomainIndexClause
diff --git
a/parser/sql/engine/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/engine/oracle/visitor/statement/type/OracleDDLStatementVisitor.java
b/parser/sql/engine/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/engine/oracle/visitor/statement/type/OracleDDLStatementVisitor.java
index 9afefc6729e..71b2c737713 100644
---
a/parser/sql/engine/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/engine/oracle/visitor/statement/type/OracleDDLStatementVisitor.java
+++
b/parser/sql/engine/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/engine/oracle/visitor/statement/type/OracleDDLStatementVisitor.java
@@ -906,15 +906,20 @@ public final class OracleDDLStatementVisitor extends
OracleStatementVisitor impl
public ASTNode visitCreateIndex(final CreateIndexContext ctx) {
SimpleTableSegment table = null;
Collection<ColumnSegment> columns = Collections.emptyList();
+ String indexType = null;
if (null != ctx.createIndexDefinitionClause().tableIndexClause()) {
table = (SimpleTableSegment)
visit(ctx.createIndexDefinitionClause().tableIndexClause().tableName());
columns = ((CollectionValue)
visit(ctx.createIndexDefinitionClause().tableIndexClause().indexExpressions())).getValue();
+ if (null !=
ctx.createIndexDefinitionClause().tableIndexClause().indexProperties()
+ && null !=
ctx.createIndexDefinitionClause().tableIndexClause().indexProperties().domainIndexClause())
{
+ indexType =
ctx.createIndexDefinitionClause().tableIndexClause().indexProperties().domainIndexClause().indexTypeName().getText();
+ }
}
IndexSegment index = (IndexSegment) visit(ctx.indexName());
if (null != ctx.createIndexSpecification() && null !=
ctx.createIndexSpecification().UNIQUE()) {
index.setUniqueKey(true);
}
- return
CreateIndexStatement.builder().databaseType(getDatabaseType()).table(table).columns(columns).index(index).build();
+ return
CreateIndexStatement.builder().databaseType(getDatabaseType()).table(table).columns(columns).index(index).indexType(indexType).build();
}
@Override
diff --git a/test/it/parser/src/main/resources/case/ddl/create-index.xml
b/test/it/parser/src/main/resources/case/ddl/create-index.xml
index c813f88ba9f..e0c1fcf7a30 100644
--- a/test/it/parser/src/main/resources/case/ddl/create-index.xml
+++ b/test/it/parser/src/main/resources/case/ddl/create-index.xml
@@ -467,4 +467,12 @@
</properties>
<comment text="full syntax" start-index="115" stop-index="127" />
</create-index>
+
+ <create-index sql-case-id="create_index_with_domain_index_type"
index-type="ctxsys.context">
+ <index name="doc_idx" start-index="13" stop-index="19" />
+ <table>
+ <simple-table name="docs" start-index="24" stop-index="27" />
+ </table>
+ <column start-index="29" stop-index="36" name="document" />
+ </create-index>
</sql-parser-test-cases>
diff --git
a/test/it/parser/src/main/resources/sql/supported/ddl/create-index.xml
b/test/it/parser/src/main/resources/sql/supported/ddl/create-index.xml
index 3602952a2df..eaae0b47f03 100644
--- a/test/it/parser/src/main/resources/sql/supported/ddl/create-index.xml
+++ b/test/it/parser/src/main/resources/sql/supported/ddl/create-index.xml
@@ -99,4 +99,5 @@
<sql-case id="create_index_doris_with_properties" value="CREATE INDEX
index1 ON table1 (column1) USING INVERTED PROPERTIES ('parser' = 'standard')"
db-types="Doris" />
<sql-case id="create_index_doris_with_comment" value="CREATE INDEX index1
ON table1 (column1) USING INVERTED COMMENT 'inverted index'" db-types="Doris" />
<sql-case id="create_index_doris_full_syntax" value="CREATE INDEX IF NOT
EXISTS index1 ON table1 (column1) USING INVERTED PROPERTIES ('parser' =
'standard') COMMENT 'full syntax'" db-types="Doris" />
+ <sql-case id="create_index_with_domain_index_type" value="CREATE INDEX
doc_idx on docs(document) indextype is ctxsys.context FILTER BY category,
author ORDER BY pub_date desc, docid PARAMETERS ('memory 500M')"
db-types="Oracle" />
</sql-cases>