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 8d8235a5863 support parsing ALTER MATERIALIZED ZONEMAP in Oracle 
(#18621)
8d8235a5863 is described below

commit 8d8235a58632d93a06a45a4aec188b200e5ff625
Author: Jiaqi Yan <[email protected]>
AuthorDate: Mon Jun 27 10:34:50 2022 +0800

    support parsing ALTER MATERIALIZED ZONEMAP in Oracle (#18621)
---
 .../src/main/antlr4/imports/oracle/DDLStatement.g4 | 19 +++++++++++++
 .../main/antlr4/imports/oracle/OracleKeyword.g4    |  8 ++++++
 .../sql/parser/autogen/OracleStatement.g4          |  1 +
 .../impl/OracleDDLStatementSQLVisitor.java         |  7 +++++
 .../core/database/visitor/SQLVisitorRule.java      |  2 ++
 .../OracleAlterMaterializedZonemapStatement.java   | 29 ++++++++++++++++++++
 .../jaxb/cases/domain/SQLParserTestCases.java      |  5 ++++
 .../AlterMaterializedZonemapStatementTestCase.java | 26 ++++++++++++++++++
 .../case/ddl/alter-materialized-zonemap.xml        | 26 ++++++++++++++++++
 .../supported/ddl/alter-materialized-zonemap.xml   | 32 ++++++++++++++++++++++
 10 files changed, 155 insertions(+)

diff --git 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/DDLStatement.g4
 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/DDLStatement.g4
index 61147b5763e..dbf38e7dba7 100644
--- 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/DDLStatement.g4
+++ 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/DDLStatement.g4
@@ -2517,3 +2517,22 @@ alterLibrary
 libraryCompileClause
     : COMPILE DEBUG? compilerParametersClause* (REUSE SETTINGS)?
     ;
+
+alterMaterializedZonemap
+    : ALTER MATERIALIZED ZONEMAP (schemaName DOT_)? zonemapName
+    ( alterZonemapAttributes
+    | zonemapRefreshClause
+    | (ENABLE | DISABLE) PRUNING
+    | COMPILE
+    | REBUILD
+    | UNUSABLE)
+    ;
+
+alterZonemapAttributes
+    : (PCTFREE INTEGER_ | PCTUSED INTEGER_ | CACHE | NOCACHE)+
+    ;
+
+zonemapRefreshClause
+    : REFRESH (FAST | COMPLETE | FORCE)?
+      (ON (DEMAND | COMMIT | LOAD | DATA MOVEMENT | LOAD DATA MOVEMENT) )?
+    ;
diff --git 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/OracleKeyword.g4
 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/OracleKeyword.g4
index 451b58c5a3a..fa08f0e57d1 100644
--- 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/OracleKeyword.g4
+++ 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/OracleKeyword.g4
@@ -2834,3 +2834,11 @@ CLEAN
 GUARANTEE
     : G U A R A N T E E
     ;
+
+PRUNING
+    : P R U N I N G
+    ;
+
+DEMAND
+    : D E M A N D
+    ;
diff --git 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/OracleStatement.g4
 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/OracleStatement.g4
index 09de5e88276..bd02d3608e8 100644
--- 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/OracleStatement.g4
+++ 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/OracleStatement.g4
@@ -108,5 +108,6 @@ execute
     | dropRestorePoint
     | dropOperator
     | alterLibrary
+    | alterMaterializedZonemap
     ) SEMI_?
     ;
diff --git 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/impl/OracleDDLStatementSQLVisitor.java
 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/impl/OracleDDLStatementSQLVisitor.java
index d370fb4a130..6284c74ce04 100644
--- 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/impl/OracleDDLStatementSQLVisitor.java
+++ 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/impl/OracleDDLStatementSQLVisitor.java
@@ -32,6 +32,7 @@ import 
org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.AlterD
 import 
org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.AlterDimensionContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.AlterFlashbackArchiveContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.AlterLibraryContext;
+import 
org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.AlterMaterializedZonemapContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.AlterIndexContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.AlterOutlineContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.AlterPackageContext;
@@ -144,6 +145,7 @@ import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.ddl.Ora
 import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.ddl.OracleAlterFlashbackArchiveStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.ddl.OracleAlterIndexStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.ddl.OracleAlterLibraryStatement;
+import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.ddl.OracleAlterMaterializedZonemapStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.ddl.OracleAlterOutlineStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.ddl.OracleAlterPackageStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.ddl.OracleAlterSequenceStatement;
@@ -885,4 +887,9 @@ public final class OracleDDLStatementSQLVisitor extends 
OracleStatementSQLVisito
     public ASTNode visitAlterLibrary(final AlterLibraryContext ctx) {
         return new OracleAlterLibraryStatement();
     }
+    
+    @Override
+    public ASTNode visitAlterMaterializedZonemap(final 
AlterMaterializedZonemapContext ctx) {
+        return new OracleAlterMaterializedZonemapStatement();
+    }
 }
diff --git 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/core/database/visitor/SQLVisitorRule.java
 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/core/database/visitor/SQLVisitorRule.java
index df8bc4c57ca..2a01a3a3204 100644
--- 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/core/database/visitor/SQLVisitorRule.java
+++ 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/core/database/visitor/SQLVisitorRule.java
@@ -566,6 +566,8 @@ public enum SQLVisitorRule {
     
     ALTER_LIBRARY("AlterLibrary", SQLStatementType.DDL),
     
+    ALTER_MATERIALIZED_ZONEMAP("AlterMaterializedZonemap", 
SQLStatementType.DDL),
+    
     CURSOR("Cursor", SQLStatementType.DDL),
     
     CLOSE("Close", SQLStatementType.DDL),
diff --git 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/oracle/ddl/OracleAlterMaterializedZonemapStatement.java
 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/oracle/ddl/OracleAlterMaterializedZonemapStatement.java
new file mode 100644
index 00000000000..07ba71cad0e
--- /dev/null
+++ 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/oracle/ddl/OracleAlterMaterializedZonemapStatement.java
@@ -0,0 +1,29 @@
+/*
+ * 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 lombok.ToString;
+import 
org.apache.shardingsphere.sql.parser.sql.common.statement.AbstractSQLStatement;
+import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.OracleStatement;
+
+/**
+ * Oracle alter materialized zonemap statement.
+ */
+@ToString
+public final class OracleAlterMaterializedZonemapStatement extends 
AbstractSQLStatement implements OracleStatement {
+}
diff --git 
a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/SQLParserTestCases.java
 
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/SQLParserTestCases.java
index 173976eac2b..100c2652324 100644
--- 
a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/SQLParserTestCases.java
+++ 
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/SQLParserTestCases.java
@@ -112,6 +112,7 @@ import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain
 import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.ddl.AlterLanguageStatementTestCase;
 import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.ddl.AlterLibraryStatementTestCase;
 import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.ddl.AlterMaterializedViewStatementTestCase;
+import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.ddl.AlterMaterializedZonemapStatementTestCase;
 import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.ddl.AlterOperatorStatementTestCase;
 import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.ddl.AlterOutlineStatementTestCase;
 import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.ddl.AlterPackageStatementTestCase;
@@ -1459,6 +1460,9 @@ public final class SQLParserTestCases {
     @XmlElement(name = "alter-library")
     private final List<AlterLibraryStatementTestCase> alterLibraryTestCases = 
new LinkedList<>();
     
+    @XmlElement(name = "alter-materialized-zonemap")
+    private final List<AlterMaterializedZonemapStatementTestCase> 
alterMaterializedZonemapTestCases = new LinkedList<>();
+    
     @XmlElement(name = "cursor")
     private final List<CursorStatementTestCase> cursorTestCases = new 
LinkedList<>();
     
@@ -1842,6 +1846,7 @@ public final class SQLParserTestCases {
         putAll(createRestorePointTestCases, result);
         putAll(dropRestorePointTestCases, result);
         putAll(alterLibraryTestCases, result);
+        putAll(alterMaterializedZonemapTestCases, result);
         putAll(cursorTestCases, result);
         putAll(closeTestCases, result);
         putAll(moveTestCases, result);
diff --git 
a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/ddl/AlterMaterializedZonemapStatementTestCase.java
 
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/ddl/AlterMaterializedZonemapStatementTestCase.java
new file mode 100644
index 00000000000..1cbe012a31c
--- /dev/null
+++ 
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/ddl/AlterMaterializedZonemapStatementTestCase.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.sql.parser.parameterized.jaxb.cases.domain.statement.ddl;
+
+import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.SQLParserTestCase;
+
+/**
+ * Alter materialized zonemap statement test case.
+ */
+public final class AlterMaterializedZonemapStatementTestCase extends 
SQLParserTestCase {
+}
diff --git 
a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ddl/alter-materialized-zonemap.xml
 
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ddl/alter-materialized-zonemap.xml
new file mode 100644
index 00000000000..14b1e3640e7
--- /dev/null
+++ 
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ddl/alter-materialized-zonemap.xml
@@ -0,0 +1,26 @@
+<?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>
+    <alter-materialized-zonemap 
sql-case-id="alter_materialized_zonemap_with_pctgree" />
+    <alter-materialized-zonemap 
sql-case-id="alter_materialized_zonemap_with_refresh" />
+    <alter-materialized-zonemap 
sql-case-id="alter_materialized_zonemap_with_disable" />
+    <alter-materialized-zonemap 
sql-case-id="alter_materialized_zonemap_with_compile" />
+    <alter-materialized-zonemap 
sql-case-id="alter_materialized_zonemap_with_rebuild" />
+    <alter-materialized-zonemap 
sql-case-id="alter_materialized_zonemap_with_unusable" />
+</sql-parser-test-cases>
diff --git 
a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/alter-materialized-zonemap.xml
 
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/alter-materialized-zonemap.xml
new file mode 100644
index 00000000000..35c885a0970
--- /dev/null
+++ 
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/alter-materialized-zonemap.xml
@@ -0,0 +1,32 @@
+<?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="alter_materialized_zonemap_with_pctgree" value="ALTER 
MATERIALIZED ZONEMAP sales_zmap
+                                                       PCTFREE 20 PCTUSED 50 
NOCACHE;" db-types="Oracle" />
+    <sql-case id="alter_materialized_zonemap_with_refresh" value="ALTER 
MATERIALIZED ZONEMAP sales_zmap
+                                                       REFRESH FAST ON 
COMMIT;" db-types="Oracle" />
+    <sql-case id="alter_materialized_zonemap_with_disable" value="ALTER 
MATERIALIZED ZONEMAP sales_zmap
+                                                       DISABLE PRUNING;" 
db-types="Oracle" />
+    <sql-case id="alter_materialized_zonemap_with_compile" value="ALTER 
MATERIALIZED ZONEMAP sales_zmap
+                                                       COMPILE;" 
db-types="Oracle" />
+    <sql-case id="alter_materialized_zonemap_with_rebuild" value="ALTER 
MATERIALIZED ZONEMAP sales_zmap
+                                                       REBUILD;" 
db-types="Oracle" />
+    <sql-case id="alter_materialized_zonemap_with_unusable" value="ALTER 
MATERIALIZED ZONEMAP sales_zmap
+                                                       UNUSABLE;" 
db-types="Oracle" />
+</sql-cases>

Reply via email to