This is an automated email from the ASF dual-hosted git repository.

liangda 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 3d0bcd85f73 Support Parsing DROP RULE in openGauss (#18034)
3d0bcd85f73 is described below

commit 3d0bcd85f730eccbed819463433515233fee7c66
Author: Everly Precia Suresh <[email protected]>
AuthorDate: Sun May 29 04:07:05 2022 +0530

    Support Parsing DROP RULE in openGauss (#18034)
---
 .../sql/parser/autogen/OpenGaussStatement.g4       |  1 +
 .../impl/OpenGaussDDLStatementSQLVisitor.java      |  7 ++++++
 .../opengauss/ddl/OpenGaussDropRuleStatement.java  | 29 ++++++++++++++++++++++
 .../main/resources/sql/supported/ddl/drop-rule.xml |  4 +--
 4 files changed, 39 insertions(+), 2 deletions(-)

diff --git 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/OpenGaussStatement.g4
 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/OpenGaussStatement.g4
index 2a0cdbc51a6..a105816c081 100644
--- 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/OpenGaussStatement.g4
+++ 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/OpenGaussStatement.g4
@@ -85,6 +85,7 @@ execute
     | dropDatabase
     | dropFunction
     | dropProcedure
+    | dropRule
     | dropServer
     | dropTrigger
     | dropView
diff --git 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/java/org/apache/shardingsphere/sql/parser/opengauss/visitor/statement/impl/OpenGaussDDLStatementSQLVisitor.java
 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/java/org/apache/shardingsphere/sql/parser/opengauss/visitor/statement/impl/OpenGaussDDLStatementSQLVisitor.java
index da1b7616058..bce360ec22a 100644
--- 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/java/org/apache/shardingsphere/sql/parser/opengauss/visitor/statement/impl/OpenGaussDDLStatementSQLVisitor.java
+++ 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/java/org/apache/shardingsphere/sql/parser/opengauss/visitor/statement/impl/OpenGaussDDLStatementSQLVisitor.java
@@ -81,6 +81,7 @@ import 
org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.Dec
 import 
org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.DropColumnSpecificationContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.DropConstraintSpecificationContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.DropCastContext;
+import 
org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.DropRuleContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.DropConversionContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.DropDatabaseContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.DropDomainContext;
@@ -190,6 +191,7 @@ import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.
 import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussDeallocateStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussDeclareStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussDropCastStatement;
+import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussDropRuleStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussDropConversionStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussDropDatabaseStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussDropDomainStatement;
@@ -638,6 +640,11 @@ public final class OpenGaussDDLStatementSQLVisitor extends 
OpenGaussStatementSQL
         return new OpenGaussDropCastStatement();
     }
     
+    @Override
+    public ASTNode visitDropRule(final DropRuleContext ctx) {
+        return new OpenGaussDropRuleStatement();
+    }
+    
     @Override
     public ASTNode visitCreateDatabase(final CreateDatabaseContext ctx) {
         OpenGaussCreateDatabaseStatement result = new 
OpenGaussCreateDatabaseStatement();
diff --git 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/opengauss/ddl/OpenGaussDropRuleStatement.java
 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/opengauss/ddl/OpenGaussDropRuleStatement.java
new file mode 100644
index 00000000000..ae9dabc9027
--- /dev/null
+++ 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/opengauss/ddl/OpenGaussDropRuleStatement.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.opengauss.ddl;
+
+import lombok.ToString;
+import 
org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.DropRuleStatement;
+import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.OpenGaussStatement;
+
+/**
+ * OpenGauss drop rule statement.
+ */
+@ToString
+public final class OpenGaussDropRuleStatement extends DropRuleStatement 
implements OpenGaussStatement {
+}
diff --git 
a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/drop-rule.xml
 
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/drop-rule.xml
index ebcbff7d287..bd76baaf302 100644
--- 
a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/drop-rule.xml
+++ 
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/drop-rule.xml
@@ -17,6 +17,6 @@
   -->
 
 <sql-cases>
-    <sql-case id="drop_rule_if_exists" value="DROP RULE IF EXISTS foo ON 
no_such_schema.bar;" db-types="PostgreSQL" />
-    <sql-case id="drop_rule" value="drop rule def_view_test_ins on 
def_view_test;" db-types="PostgreSQL" />
+    <sql-case id="drop_rule_if_exists" value="DROP RULE IF EXISTS foo ON 
no_such_schema.bar;" db-types="PostgreSQL,openGauss" />
+    <sql-case id="drop_rule" value="drop rule def_view_test_ins on 
def_view_test;" db-types="PostgreSQL,openGauss" />
 </sql-cases>

Reply via email to