You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by du...@apache.org on 2022/05/31 05:41:22 UTC

[shardingsphere] branch master updated: Support Parsing DROP TYPE in openGauss (#18088)

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 14164cf509a Support Parsing DROP TYPE in openGauss (#18088)
14164cf509a is described below

commit 14164cf509ab8374e6c463d27641a5a98ec05fa6
Author: Everly Precia Suresh <77...@users.noreply.github.com>
AuthorDate: Tue May 31 11:11:17 2022 +0530

    Support Parsing DROP TYPE in openGauss (#18088)
---
 .../sql/parser/autogen/OpenGaussStatement.g4       |  1 +
 .../impl/OpenGaussDDLStatementSQLVisitor.java      |  7 ++++++
 .../opengauss/ddl/OpenGaussDropTypeStatement.java  | 29 ++++++++++++++++++++++
 .../src/main/resources/case/ddl/drop-type.xml      |  1 +
 .../main/resources/sql/supported/ddl/drop-type.xml |  9 ++++---
 5 files changed, 43 insertions(+), 4 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 0f35795134c..96f55329fcc 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
@@ -81,6 +81,7 @@ execute
     | alterSchema
     | dropSchema
     | createType
+    | dropType
     | createTextSearch
     | dropDatabase
     | dropFunction
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 157e3ea05b5..c000380ae32 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
@@ -94,6 +94,7 @@ import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.Dro
 import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.DropSchemaContext;
 import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.DropSequenceContext;
 import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.DropSynonymContext;
+import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.DropTypeContext;
 import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.DropDirectoryContext;
 import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.DropTableContext;
 import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.DropTablespaceContext;
@@ -205,6 +206,7 @@ import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.
 import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussDropSchemaStatement;
 import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussDropSequenceStatement;
 import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussDropSynonymStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussDropTypeStatement;
 import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussDropDirectoryStatement;
 import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussDropTableStatement;
 import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussDropTablespaceStatement;
@@ -680,6 +682,11 @@ public final class OpenGaussDDLStatementSQLVisitor extends OpenGaussStatementSQL
         return new OpenGaussDropSynonymStatement();
     }
     
+    @Override
+    public ASTNode visitDropType(final DropTypeContext ctx) {
+        return new OpenGaussDropTypeStatement();
+    }
+    
     @Override
     public ASTNode visitDropDirectory(final DropDirectoryContext ctx) {
         return new OpenGaussDropDirectoryStatement();
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/opengauss/ddl/OpenGaussDropTypeStatement.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/opengauss/ddl/OpenGaussDropTypeStatement.java
new file mode 100644
index 00000000000..05515b35ed0
--- /dev/null
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/opengauss/ddl/OpenGaussDropTypeStatement.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.DropTypeStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.OpenGaussStatement;
+
+/**
+ * OpenGauss drop type statement.
+ */
+@ToString
+public final class OpenGaussDropTypeStatement extends DropTypeStatement implements OpenGaussStatement {
+}
diff --git a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ddl/drop-type.xml b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ddl/drop-type.xml
index d839f6a7e63..4d706e5370a 100644
--- a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ddl/drop-type.xml
+++ b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ddl/drop-type.xml
@@ -21,4 +21,5 @@
     <drop-type sql-case-id="drop_type_cascade" />
     <drop-type sql-case-id="drop_type_restrict" />
     <drop-type sql-case-id="drop_type_if_exists" />
+    <drop-type sql-case-id="drop_type_namelist" />
 </sql-parser-test-cases>
diff --git a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/drop-type.xml b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/drop-type.xml
index 0e4079495e2..90759b8b98d 100644
--- a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/drop-type.xml
+++ b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/drop-type.xml
@@ -17,8 +17,9 @@
   -->
 
 <sql-cases>
-    <sql-case id="drop_type" value="DROP TYPE base_type" db-types="PostgreSQL" />
-    <sql-case id="drop_type_cascade" value="DROP TYPE base_type CASCADE" db-types="PostgreSQL" />
-    <sql-case id="drop_type_restrict" value="DROP TYPE base_type RESTRICT" db-types="PostgreSQL" />
-    <sql-case id="drop_type_if_exists" value="DROP TYPE IF EXISTS base_type RESTRICT" db-types="PostgreSQL" />
+    <sql-case id="drop_type" value="DROP TYPE base_type" db-types="PostgreSQL,openGauss" />
+    <sql-case id="drop_type_cascade" value="DROP TYPE base_type CASCADE" db-types="PostgreSQL,openGauss" />
+    <sql-case id="drop_type_restrict" value="DROP TYPE base_type RESTRICT" db-types="PostgreSQL,openGauss" />
+    <sql-case id="drop_type_if_exists" value="DROP TYPE IF EXISTS base_type RESTRICT" db-types="PostgreSQL,openGauss" />
+    <sql-case id="drop_type_namelist" value="DROP TYPE IF EXISTS t1,t2 RESTRICT" db-types="openGauss" />
 </sql-cases>