From 81ce5f1e26b55323f56d2fe8e6cd75a4a0f1cc45 Mon Sep 17 00:00:00 2001 From: duanzhengqiang Date: Thu, 9 Jan 2025 12:43:22 +0800 Subject: [PATCH] Minor refactor for view statement --- .../visitor/statement/type/DorisDDLStatementVisitor.java | 1 + .../statement/type/OpenGaussDDLStatementVisitor.java | 1 + .../statement/type/PostgreSQLDDLStatementVisitor.java | 1 + .../visitor/statement/type/PrestoDDLStatementVisitor.java | 1 + .../statement/type/SQLServerDDLStatementVisitor.java | 1 + .../parser/statement/doris/ddl/DorisDropViewStatement.java | 6 ++++++ .../statement/opengauss/ddl/OpenGaussDropViewStatement.java | 6 ++++++ .../postgresql/ddl/PostgreSQLDropViewStatement.java | 6 ++++++ .../statement/presto/ddl/PrestoDropViewStatement.java | 6 ++++++ .../statement/sqlserver/ddl/SQLServerDropViewStatement.java | 6 ++++++ 10 files changed, 35 insertions(+) diff --git a/parser/sql/dialect/doris/src/main/java/org/apache/shardingsphere/sql/parser/doris/visitor/statement/type/DorisDDLStatementVisitor.java b/parser/sql/dialect/doris/src/main/java/org/apache/shardingsphere/sql/parser/doris/visitor/statement/type/DorisDDLStatementVisitor.java index 5acd3f672be89..0813a7db2d287 100644 --- a/parser/sql/dialect/doris/src/main/java/org/apache/shardingsphere/sql/parser/doris/visitor/statement/type/DorisDDLStatementVisitor.java +++ b/parser/sql/dialect/doris/src/main/java/org/apache/shardingsphere/sql/parser/doris/visitor/statement/type/DorisDDLStatementVisitor.java @@ -226,6 +226,7 @@ public ASTNode visitAlterView(final AlterViewContext ctx) { @Override public ASTNode visitDropView(final DropViewContext ctx) { DorisDropViewStatement result = new DorisDropViewStatement(); + result.setIfExists(null != ctx.ifExists()); result.getViews().addAll(((CollectionValue) visit(ctx.viewNames())).getValue()); return result; } diff --git a/parser/sql/dialect/opengauss/src/main/java/org/apache/shardingsphere/sql/parser/opengauss/visitor/statement/type/OpenGaussDDLStatementVisitor.java b/parser/sql/dialect/opengauss/src/main/java/org/apache/shardingsphere/sql/parser/opengauss/visitor/statement/type/OpenGaussDDLStatementVisitor.java index cfba7147d0d11..3c42b14e69a45 100644 --- a/parser/sql/dialect/opengauss/src/main/java/org/apache/shardingsphere/sql/parser/opengauss/visitor/statement/type/OpenGaussDDLStatementVisitor.java +++ b/parser/sql/dialect/opengauss/src/main/java/org/apache/shardingsphere/sql/parser/opengauss/visitor/statement/type/OpenGaussDDLStatementVisitor.java @@ -666,6 +666,7 @@ public ASTNode visitDropFunction(final DropFunctionContext ctx) { @Override public ASTNode visitDropView(final DropViewContext ctx) { OpenGaussDropViewStatement result = new OpenGaussDropViewStatement(); + result.setIfExists(null != ctx.ifExists()); result.getViews().addAll(((CollectionValue) visit(ctx.qualifiedNameList())).getValue()); return result; } diff --git a/parser/sql/dialect/postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/statement/type/PostgreSQLDDLStatementVisitor.java b/parser/sql/dialect/postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/statement/type/PostgreSQLDDLStatementVisitor.java index dcc1477fbe0cb..056389cc9e01a 100644 --- a/parser/sql/dialect/postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/statement/type/PostgreSQLDDLStatementVisitor.java +++ b/parser/sql/dialect/postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/statement/type/PostgreSQLDDLStatementVisitor.java @@ -811,6 +811,7 @@ public ASTNode visitDropGroup(final DropGroupContext ctx) { @Override public ASTNode visitDropView(final DropViewContext ctx) { PostgreSQLDropViewStatement result = new PostgreSQLDropViewStatement(); + result.setIfExists(null != ctx.ifExists()); result.getViews().addAll(((CollectionValue) visit(ctx.qualifiedNameList())).getValue()); return result; } diff --git a/parser/sql/dialect/presto/src/main/java/org/apache/shardingsphere/sql/parser/presto/visitor/statement/type/PrestoDDLStatementVisitor.java b/parser/sql/dialect/presto/src/main/java/org/apache/shardingsphere/sql/parser/presto/visitor/statement/type/PrestoDDLStatementVisitor.java index f18720967b9d4..12bdecd47206e 100644 --- a/parser/sql/dialect/presto/src/main/java/org/apache/shardingsphere/sql/parser/presto/visitor/statement/type/PrestoDDLStatementVisitor.java +++ b/parser/sql/dialect/presto/src/main/java/org/apache/shardingsphere/sql/parser/presto/visitor/statement/type/PrestoDDLStatementVisitor.java @@ -67,6 +67,7 @@ public ASTNode visitCreateView(final CreateViewContext ctx) { @Override public ASTNode visitDropView(final DropViewContext ctx) { PrestoDropViewStatement result = new PrestoDropViewStatement(); + result.setIfExists(null != ctx.ifExists()); result.getViews().addAll(((CollectionValue) visit(ctx.viewNames())).getValue()); return result; } diff --git a/parser/sql/dialect/sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/sqlserver/visitor/statement/type/SQLServerDDLStatementVisitor.java b/parser/sql/dialect/sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/sqlserver/visitor/statement/type/SQLServerDDLStatementVisitor.java index f6f6c4e494c5c..91c0f2008baad 100644 --- a/parser/sql/dialect/sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/sqlserver/visitor/statement/type/SQLServerDDLStatementVisitor.java +++ b/parser/sql/dialect/sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/sqlserver/visitor/statement/type/SQLServerDDLStatementVisitor.java @@ -490,6 +490,7 @@ public ASTNode visitDropProcedure(final DropProcedureContext ctx) { @Override public ASTNode visitDropView(final DropViewContext ctx) { SQLServerDropViewStatement result = new SQLServerDropViewStatement(); + result.setIfExists(null != ctx.ifExists()); for (ViewNameContext each : ctx.viewName()) { result.getViews().add((SimpleTableSegment) visit(each)); } diff --git a/parser/sql/statement/type/doris/src/main/java/org/apache/shardingsphere/sql/parser/statement/doris/ddl/DorisDropViewStatement.java b/parser/sql/statement/type/doris/src/main/java/org/apache/shardingsphere/sql/parser/statement/doris/ddl/DorisDropViewStatement.java index c951a641cc670..eb02918ff4eb6 100644 --- a/parser/sql/statement/type/doris/src/main/java/org/apache/shardingsphere/sql/parser/statement/doris/ddl/DorisDropViewStatement.java +++ b/parser/sql/statement/type/doris/src/main/java/org/apache/shardingsphere/sql/parser/statement/doris/ddl/DorisDropViewStatement.java @@ -17,11 +17,17 @@ package org.apache.shardingsphere.sql.parser.statement.doris.ddl; +import lombok.Getter; +import lombok.Setter; import org.apache.shardingsphere.sql.parser.statement.core.statement.ddl.DropViewStatement; import org.apache.shardingsphere.sql.parser.statement.doris.DorisStatement; /** * Doris drop view statement. */ +@Getter +@Setter public final class DorisDropViewStatement extends DropViewStatement implements DorisStatement { + + private boolean ifExists; } diff --git a/parser/sql/statement/type/opengauss/src/main/java/org/apache/shardingsphere/sql/parser/statement/opengauss/ddl/OpenGaussDropViewStatement.java b/parser/sql/statement/type/opengauss/src/main/java/org/apache/shardingsphere/sql/parser/statement/opengauss/ddl/OpenGaussDropViewStatement.java index 2db288eda0cf5..fd051c10345a4 100644 --- a/parser/sql/statement/type/opengauss/src/main/java/org/apache/shardingsphere/sql/parser/statement/opengauss/ddl/OpenGaussDropViewStatement.java +++ b/parser/sql/statement/type/opengauss/src/main/java/org/apache/shardingsphere/sql/parser/statement/opengauss/ddl/OpenGaussDropViewStatement.java @@ -17,11 +17,17 @@ package org.apache.shardingsphere.sql.parser.statement.opengauss.ddl; +import lombok.Getter; +import lombok.Setter; import org.apache.shardingsphere.sql.parser.statement.core.statement.ddl.DropViewStatement; import org.apache.shardingsphere.sql.parser.statement.opengauss.OpenGaussStatement; /** * OpenGauss drop view statement. */ +@Getter +@Setter public final class OpenGaussDropViewStatement extends DropViewStatement implements OpenGaussStatement { + + private boolean ifExists; } diff --git a/parser/sql/statement/type/postgresql/src/main/java/org/apache/shardingsphere/sql/parser/statement/postgresql/ddl/PostgreSQLDropViewStatement.java b/parser/sql/statement/type/postgresql/src/main/java/org/apache/shardingsphere/sql/parser/statement/postgresql/ddl/PostgreSQLDropViewStatement.java index 13b88e4adc4e7..e07ec8832d975 100644 --- a/parser/sql/statement/type/postgresql/src/main/java/org/apache/shardingsphere/sql/parser/statement/postgresql/ddl/PostgreSQLDropViewStatement.java +++ b/parser/sql/statement/type/postgresql/src/main/java/org/apache/shardingsphere/sql/parser/statement/postgresql/ddl/PostgreSQLDropViewStatement.java @@ -17,11 +17,17 @@ package org.apache.shardingsphere.sql.parser.statement.postgresql.ddl; +import lombok.Getter; +import lombok.Setter; import org.apache.shardingsphere.sql.parser.statement.core.statement.ddl.DropViewStatement; import org.apache.shardingsphere.sql.parser.statement.postgresql.PostgreSQLStatement; /** * PostgreSQL drop view statement. */ +@Getter +@Setter public final class PostgreSQLDropViewStatement extends DropViewStatement implements PostgreSQLStatement { + + private boolean ifExists; } diff --git a/parser/sql/statement/type/presto/src/main/java/org/apache/shardingsphere/sql/parser/statement/presto/ddl/PrestoDropViewStatement.java b/parser/sql/statement/type/presto/src/main/java/org/apache/shardingsphere/sql/parser/statement/presto/ddl/PrestoDropViewStatement.java index 6dabe553f091f..8b01274218fba 100644 --- a/parser/sql/statement/type/presto/src/main/java/org/apache/shardingsphere/sql/parser/statement/presto/ddl/PrestoDropViewStatement.java +++ b/parser/sql/statement/type/presto/src/main/java/org/apache/shardingsphere/sql/parser/statement/presto/ddl/PrestoDropViewStatement.java @@ -17,11 +17,17 @@ package org.apache.shardingsphere.sql.parser.statement.presto.ddl; +import lombok.Getter; +import lombok.Setter; import org.apache.shardingsphere.sql.parser.statement.core.statement.ddl.DropViewStatement; import org.apache.shardingsphere.sql.parser.statement.presto.PrestoStatement; /** * Presto drop view statement. */ +@Getter +@Setter public final class PrestoDropViewStatement extends DropViewStatement implements PrestoStatement { + + private boolean ifExists; } diff --git a/parser/sql/statement/type/sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/statement/sqlserver/ddl/SQLServerDropViewStatement.java b/parser/sql/statement/type/sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/statement/sqlserver/ddl/SQLServerDropViewStatement.java index 7015270ef4111..4f2b95555816b 100644 --- a/parser/sql/statement/type/sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/statement/sqlserver/ddl/SQLServerDropViewStatement.java +++ b/parser/sql/statement/type/sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/statement/sqlserver/ddl/SQLServerDropViewStatement.java @@ -17,11 +17,17 @@ package org.apache.shardingsphere.sql.parser.statement.sqlserver.ddl; +import lombok.Getter; +import lombok.Setter; import org.apache.shardingsphere.sql.parser.statement.core.statement.ddl.DropViewStatement; import org.apache.shardingsphere.sql.parser.statement.sqlserver.SQLServerStatement; /** * SQLServer drop view statement. */ +@Getter +@Setter public final class SQLServerDropViewStatement extends DropViewStatement implements SQLServerStatement { + + private boolean ifExists; }