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/27 08:05:51 UTC

[shardingsphere] branch master updated: Support Parsing `DROP CAST` in openGauss (#18003)

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 27b9a541718 Support Parsing `DROP CAST` in openGauss (#18003)
27b9a541718 is described below

commit 27b9a541718a60dd342a8c8fec1e61950aa58929
Author: Everly Precia Suresh <77...@users.noreply.github.com>
AuthorDate: Fri May 27 13:35:44 2022 +0530

    Support Parsing `DROP CAST` in openGauss (#18003)
    
    * Support Parsing DROP CAST in openGauss
    
    * Support Parsing DROP CAST in openGauss
    
    * Support Parsing DROP CAST in openGauss
---
 .../sql/parser/autogen/OpenGaussStatement.g4       |  1 +
 .../impl/OpenGaussDDLStatementSQLVisitor.java      |  7 ++++++
 .../opengauss/ddl/OpenGaussDropCastStatement.java  | 29 ++++++++++++++++++++++
 .../main/resources/sql/supported/ddl/drop-cast.xml | 16 ++++++------
 4 files changed, 45 insertions(+), 8 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 989b6cfad73..c13c17f0fab 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
@@ -127,5 +127,6 @@ execute
     | alterDirectory
     | dropDirectory
     | createCast
+    | dropCast
     ) SEMI_? EOF
     ;
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 36a3979a15e..14a421b0ebf 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
@@ -79,6 +79,7 @@ import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.Dea
 import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.DeclareContext;
 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.DropConversionContext;
 import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.DropDatabaseContext;
 import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.DropDomainContext;
@@ -186,6 +187,7 @@ import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.
 import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussCursorStatement;
 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.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;
@@ -629,6 +631,11 @@ public final class OpenGaussDDLStatementSQLVisitor extends OpenGaussStatementSQL
         return new OpenGaussDropProcedureStatement();
     }
     
+    @Override
+    public ASTNode visitDropCast(final DropCastContext ctx) {
+        return new OpenGaussDropCastStatement();
+    }
+    
     @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/OpenGaussDropCastStatement.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/opengauss/ddl/OpenGaussDropCastStatement.java
new file mode 100644
index 00000000000..23a70b6e79d
--- /dev/null
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/opengauss/ddl/OpenGaussDropCastStatement.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.DropCastStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.OpenGaussStatement;
+
+/**
+ * OpenGauss drop cast statement.
+ */
+@ToString
+public final class OpenGaussDropCastStatement extends DropCastStatement implements OpenGaussStatement {
+}
diff --git a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/drop-cast.xml b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/drop-cast.xml
index 3b65b0943b0..d274748b253 100644
--- a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/drop-cast.xml
+++ b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/drop-cast.xml
@@ -17,12 +17,12 @@
   -->
 
 <sql-cases>
-    <sql-case id="drop_cast_if_exists_integer_as_no_such_schema" value="DROP CAST IF EXISTS (INTEGER AS no_such_schema.bar);" db-types="PostgreSQL" />
-    <sql-case id="drop_cast_if_exists_integer_as_no_such_type2" value="DROP CAST IF EXISTS (INTEGER AS no_such_type2);" db-types="PostgreSQL" />
-    <sql-case id="drop_cast_if_exists_no_such_schema_as_integer" value="DROP CAST IF EXISTS (no_such_schema.foo AS INTEGER);" db-types="PostgreSQL" />
-    <sql-case id="drop_cast_if_exists_no_such_type1_as_integer" value="DROP CAST IF EXISTS (no_such_type1 AS INTEGER);" db-types="PostgreSQL" />
-    <sql-case id="drop_cast_if_exists_text_as_text" value="DROP CAST IF EXISTS (text AS text);" db-types="PostgreSQL" />
-    <sql-case id="drop_cast_int4_as_casttesttype" value="DROP CAST (int4 AS casttesttype);" db-types="PostgreSQL" />
-    <sql-case id="drop_cast_text_as_casttesttype" value="DROP CAST (text AS casttesttype);" db-types="PostgreSQL" />
-    <sql-case id="drop_cast_text_as_text" value="DROP CAST (text AS text);" db-types="PostgreSQL" />
+    <sql-case id="drop_cast_if_exists_integer_as_no_such_schema" value="DROP CAST IF EXISTS (INTEGER AS no_such_schema.bar) CASCADE;" db-types="PostgreSQL,openGauss" />
+    <sql-case id="drop_cast_if_exists_integer_as_no_such_type2" value="DROP CAST IF EXISTS (INTEGER AS no_such_type2) RESTRICT;" db-types="PostgreSQL,openGauss" />
+    <sql-case id="drop_cast_if_exists_no_such_schema_as_integer" value="DROP CAST IF EXISTS (no_such_schema.foo AS INTEGER);" db-types="PostgreSQL,openGauss" />
+    <sql-case id="drop_cast_if_exists_no_such_type1_as_integer" value="DROP CAST IF EXISTS (no_such_type1 AS INTEGER);" db-types="PostgreSQL,openGauss" />
+    <sql-case id="drop_cast_if_exists_text_as_text" value="DROP CAST IF EXISTS (text AS text);" db-types="PostgreSQL,openGauss" />
+    <sql-case id="drop_cast_int4_as_casttesttype" value="DROP CAST (int4 AS casttesttype);" db-types="PostgreSQL,openGauss" />
+    <sql-case id="drop_cast_text_as_casttesttype" value="DROP CAST (text AS casttesttype);" db-types="PostgreSQL,openGauss" />
+    <sql-case id="drop_cast_text_as_text" value="DROP CAST (text AS text);" db-types="PostgreSQL,openGauss" />
 </sql-cases>