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 fb0d1d4b487 Support parsing Oracle Create Outline SQL (#31283)
fb0d1d4b487 is described below

commit fb0d1d4b48743f24ee2d412a2dd98022297c08af
Author: Thanoshan MV <[email protected]>
AuthorDate: Sun May 19 13:31:48 2024 +0530

    Support parsing Oracle Create Outline SQL (#31283)
    
    * Added support for Oracle create outline statement
    
    * Undo unwanted import changes and added a new line at the end of the file
    
    * Fix checkstyle issues
---
 .../src/main/antlr4/imports/oracle/DDLStatement.g4 |  5 ++++
 .../sql/parser/autogen/OracleStatement.g4          |  1 +
 .../statement/type/OracleDDLStatementVisitor.java  |  7 ++++++
 .../core/database/visitor/SQLVisitorRule.java      |  2 ++
 .../statement/ddl/CreateOutlineStatement.java      | 26 +++++++++++++++++++++
 .../oracle/ddl/OracleCreateOutlineStatement.java   | 27 ++++++++++++++++++++++
 .../cases/parser/jaxb/RootSQLParserTestCases.java  |  4 ++++
 .../ddl/CreateOutlineStatementTestCase.java        | 26 +++++++++++++++++++++
 .../src/main/resources/case/ddl/create-outline.xml | 23 ++++++++++++++++++
 .../resources/sql/supported/ddl/create-outline.xml | 23 ++++++++++++++++++
 10 files changed, 144 insertions(+)

diff --git 
a/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/DDLStatement.g4 
b/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/DDLStatement.g4
index 720889d0630..52b570d5968 100644
--- a/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/DDLStatement.g4
+++ b/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/DDLStatement.g4
@@ -4325,3 +4325,8 @@ noAuditTraditional
 dropDatabase
     : DROP DATABASE (INCLUDING BACKUPS)? NOPROMPT?
     ;
+
+createOutline
+    : CREATE (OR REPLACE)? (PUBLIC | PRIVATE)? OUTLINE outlineName?
+    (FROM (PUBLIC | PRIVATE)? outlineName)? (FOR CATEGORY categoryName)? (ON 
(select | delete | update | insert | createTable))?
+    ;
diff --git 
a/parser/sql/dialect/oracle/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/OracleStatement.g4
 
b/parser/sql/dialect/oracle/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/OracleStatement.g4
index 04ad915da7e..bfb53379716 100644
--- 
a/parser/sql/dialect/oracle/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/OracleStatement.g4
+++ 
b/parser/sql/dialect/oracle/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/OracleStatement.g4
@@ -163,5 +163,6 @@ execute
     | show
     | spool
     | createOperator
+    | createOutline
     ) SEMI_? SLASH_? EOF
     ;
diff --git 
a/parser/sql/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/type/OracleDDLStatementVisitor.java
 
b/parser/sql/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/type/OracleDDLStatementVisitor.java
index e8b5022728b..34951f47fee 100644
--- 
a/parser/sql/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/type/OracleDDLStatementVisitor.java
+++ 
b/parser/sql/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/type/OracleDDLStatementVisitor.java
@@ -92,6 +92,7 @@ import 
org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.Create
 import 
org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.CreateMaterializedViewContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.CreateMaterializedViewLogContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.CreateOperatorContext;
+import 
org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.CreateOutlineContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.CreatePFileContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.CreateProcedureContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.CreateProfileContext;
@@ -288,6 +289,7 @@ import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.ddl.Ora
 import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.ddl.OracleCreateNestedTableTypeStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.ddl.OracleCreateObjectTypeStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.ddl.OracleCreateOperatorStatement;
+import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.ddl.OracleCreateOutlineStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.ddl.OracleCreatePFileStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.ddl.OracleCreateProcedureStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.ddl.OracleCreateProfileStatement;
@@ -1767,4 +1769,9 @@ public final class OracleDDLStatementVisitor extends 
OracleStatementVisitor impl
     public ASTNode visitCreateOperator(final CreateOperatorContext ctx) {
         return new OracleCreateOperatorStatement();
     }
+    
+    @Override
+    public ASTNode visitCreateOutline(final CreateOutlineContext ctx) {
+        return new OracleCreateOutlineStatement();
+    }
 }
diff --git 
a/parser/sql/engine/src/main/java/org/apache/shardingsphere/sql/parser/core/database/visitor/SQLVisitorRule.java
 
b/parser/sql/engine/src/main/java/org/apache/shardingsphere/sql/parser/core/database/visitor/SQLVisitorRule.java
index 9c91a867b43..9f1693db60a 100644
--- 
a/parser/sql/engine/src/main/java/org/apache/shardingsphere/sql/parser/core/database/visitor/SQLVisitorRule.java
+++ 
b/parser/sql/engine/src/main/java/org/apache/shardingsphere/sql/parser/core/database/visitor/SQLVisitorRule.java
@@ -573,6 +573,8 @@ public enum SQLVisitorRule {
     
     ALTER_OUTLINE("AlterOutline", SQLStatementType.DDL),
     
+    CREATE_OUTLINE("CreateOutline", SQLStatementType.DDL),
+    
     ALTER_ANALYTIC_VIEW("AlterAnalyticView", SQLStatementType.DDL),
     
     DROP_EDITION("DropEdition", SQLStatementType.DDL),
diff --git 
a/parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/ddl/CreateOutlineStatement.java
 
b/parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/ddl/CreateOutlineStatement.java
new file mode 100644
index 00000000000..7ece81f8ed4
--- /dev/null
+++ 
b/parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/ddl/CreateOutlineStatement.java
@@ -0,0 +1,26 @@
+/*
+ * 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.statement.ddl;
+
+import 
org.apache.shardingsphere.sql.parser.sql.common.statement.AbstractSQLStatement;
+
+/**
+ * Create outline statement.
+ */
+public abstract class CreateOutlineStatement extends AbstractSQLStatement 
implements DDLStatement {
+}
diff --git 
a/parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/oracle/ddl/OracleCreateOutlineStatement.java
 
b/parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/oracle/ddl/OracleCreateOutlineStatement.java
new file mode 100644
index 00000000000..88a6949f5a5
--- /dev/null
+++ 
b/parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/oracle/ddl/OracleCreateOutlineStatement.java
@@ -0,0 +1,27 @@
+/*
+ * 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.dialect.statement.oracle.ddl;
+
+import 
org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.CreateOutlineStatement;
+import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.OracleStatement;
+
+/**
+ * Oracle create outline statement.
+ */
+public final class OracleCreateOutlineStatement extends CreateOutlineStatement 
implements OracleStatement {
+}
diff --git 
a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/RootSQLParserTestCases.java
 
b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/RootSQLParserTestCases.java
index 4f69a5eb3a4..4b3e7ecb78f 100644
--- 
a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/RootSQLParserTestCases.java
+++ 
b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/RootSQLParserTestCases.java
@@ -191,6 +191,7 @@ import 
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.s
 import 
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.CreateMaterializedViewLogStatementTestCase;
 import 
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.CreateMaterializedViewStatementTestCase;
 import 
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.CreateOperatorStatementTestCase;
+import 
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.CreateOutlineStatementTestCase;
 import 
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.CreatePFileStatementTestCase;
 import 
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.CreatePolicyStatementTestCase;
 import 
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.CreateProfileStatementTestCase;
@@ -1753,6 +1754,9 @@ public final class RootSQLParserTestCases {
     @XmlElement(name = "start-replica")
     private final List<StartReplicaStatementTestCase> 
startReplicaStatementTestCases = new LinkedList<>();
     
+    @XmlElement(name = "create-outline")
+    private final List<CreateOutlineStatementTestCase> 
createOutlineStatementTestCases = new LinkedList<>();
+    
     /**
      * Get all SQL parser test cases.
      *
diff --git 
a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/ddl/CreateOutlineStatementTestCase.java
 
b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/ddl/CreateOutlineStatementTestCase.java
new file mode 100644
index 00000000000..a5f0bc986d2
--- /dev/null
+++ 
b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/ddl/CreateOutlineStatementTestCase.java
@@ -0,0 +1,26 @@
+/*
+ * 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.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl;
+
+import 
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.SQLParserTestCase;
+
+/**
+ * Create outline statement test case.
+ */
+public final class CreateOutlineStatementTestCase extends SQLParserTestCase {
+}
diff --git a/test/it/parser/src/main/resources/case/ddl/create-outline.xml 
b/test/it/parser/src/main/resources/case/ddl/create-outline.xml
new file mode 100644
index 00000000000..3581f4a5756
--- /dev/null
+++ b/test/it/parser/src/main/resources/case/ddl/create-outline.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+
+<sql-parser-test-cases>
+    <create-outline sql-case-id="create_outline_for_category" />
+    <create-outline sql-case-id="create_or_replace_private_outline" />
+    <create-outline sql-case-id="create_or_replace_outline" />
+</sql-parser-test-cases>
diff --git 
a/test/it/parser/src/main/resources/sql/supported/ddl/create-outline.xml 
b/test/it/parser/src/main/resources/sql/supported/ddl/create-outline.xml
new file mode 100644
index 00000000000..10bdf0ee735
--- /dev/null
+++ b/test/it/parser/src/main/resources/sql/supported/ddl/create-outline.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+
+<sql-cases>
+    <sql-case id="create_outline_for_category" value="CREATE OUTLINE salaries 
FOR CATEGORY special ON SELECT last_name, salary FROM employees;" 
db-types="Oracle" />
+    <sql-case id="create_or_replace_private_outline" value="CREATE OR REPLACE 
PRIVATE OUTLINE my_salaries FROM salaries;" db-types="Oracle" />
+    <sql-case id="create_or_replace_outline" value="CREATE OR REPLACE OUTLINE 
public_salaries FROM PRIVATE my_salaries;" db-types="Oracle" />
+</sql-cases>

Reply via email to