This is an automated email from the ASF dual-hosted git repository.
zhangliang 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 433a566c3ea Support parsing Doris CANCEL/SHOW ALTER TABLE syntax
(#38113)
433a566c3ea is described below
commit 433a566c3ea87702a70cf945d9ec8ba1435485a0
Author: cxy <[email protected]>
AuthorDate: Sat Feb 21 14:46:13 2026 +0800
Support parsing Doris CANCEL/SHOW ALTER TABLE syntax (#38113)
* Support parsing Doris CANCEL/SHOW ALTER TABLE syntax
* Fix SQL case syntax for cancel alter table
---
.../core/database/visitor/SQLVisitorRule.java | 4 +
.../src/main/antlr4/imports/doris/DALStatement.g4 | 5 ++
.../src/main/antlr4/imports/doris/DDLStatement.g4 | 4 +
.../sql/parser/autogen/DorisStatement.g4 | 1 +
.../statement/type/DorisDALStatementVisitor.java | 26 ++++++
.../statement/type/DorisDDLStatementVisitor.java | 21 +++++
.../type/dal/ShowAlterTableStatement.java | 95 +++++++++++++++++++++
.../type/ddl/alter/CancelAlterTableStatement.java | 54 ++++++++++++
.../dal/standard/StandardDALStatementAssert.java | 5 ++
.../type/ShowAlterTableStatementAssert.java | 98 ++++++++++++++++++++++
.../ddl/standard/StandardDDLStatementAssert.java | 5 ++
.../type/CancelAlterTableStatementAssert.java | 74 ++++++++++++++++
.../cases/parser/jaxb/RootSQLParserTestCases.java | 8 ++
.../dal/ShowAlterTableStatementTestCase.java | 52 ++++++++++++
.../alter/CancelAlterTableStatementTestCase.java | 45 ++++++++++
.../main/resources/case/dal/show-alter-table.xml | 90 ++++++++++++++++++++
.../main/resources/case/ddl/cancel-alter-table.xml | 70 ++++++++++++++++
.../sql/supported/dal/show-alter-table.xml | 28 +++++++
.../sql/supported/ddl/cancel-alter-table.xml | 27 ++++++
19 files changed, 712 insertions(+)
diff --git
a/parser/sql/engine/core/src/main/java/org/apache/shardingsphere/sql/parser/engine/core/database/visitor/SQLVisitorRule.java
b/parser/sql/engine/core/src/main/java/org/apache/shardingsphere/sql/parser/engine/core/database/visitor/SQLVisitorRule.java
index fcfddecf049..fe7309c35ef 100644
---
a/parser/sql/engine/core/src/main/java/org/apache/shardingsphere/sql/parser/engine/core/database/visitor/SQLVisitorRule.java
+++
b/parser/sql/engine/core/src/main/java/org/apache/shardingsphere/sql/parser/engine/core/database/visitor/SQLVisitorRule.java
@@ -99,6 +99,8 @@ public enum SQLVisitorRule {
CANCEL_BUILD_INDEX("CancelBuildIndex", SQLStatementType.DDL),
+ CANCEL_ALTER_TABLE("CancelAlterTable", SQLStatementType.DDL),
+
CREATE_PROCEDURE("CreateProcedure", SQLStatementType.DDL),
CREATE_PUBLICATION("CreatePublication", SQLStatementType.DDL),
@@ -443,6 +445,8 @@ public enum SQLVisitorRule {
DESC_FUNCTION("DescFunction", SQLStatementType.DAL),
+ SHOW_ALTER_TABLE("ShowAlterTable", SQLStatementType.DAL),
+
SET_VARIABLE("SetVariable", SQLStatementType.DAL),
UNSET_VARIABLE("UnsetVariable", SQLStatementType.DAL),
diff --git
a/parser/sql/engine/dialect/doris/src/main/antlr4/imports/doris/DALStatement.g4
b/parser/sql/engine/dialect/doris/src/main/antlr4/imports/doris/DALStatement.g4
index c269dc08105..62c7703cea5 100644
---
a/parser/sql/engine/dialect/doris/src/main/antlr4/imports/doris/DALStatement.g4
+++
b/parser/sql/engine/dialect/doris/src/main/antlr4/imports/doris/DALStatement.g4
@@ -195,6 +195,10 @@ showBuildIndex
: SHOW BUILD INDEX fromDatabase? showWhereClause? orderByClause?
limitClause?
;
+showAlterTable
+ : SHOW ALTER TABLE (COLUMN | ROLLUP)? fromDatabase? showWhereClause?
orderByClause? limitClause?
+ ;
+
showMasterStatus
: SHOW MASTER STATUS
;
@@ -774,6 +778,7 @@ show
| showColumns
| showIndex
| showBuildIndex
+ | showAlterTable
| showCreateDatabase
| showCreateTable
| showBinlogEvents
diff --git
a/parser/sql/engine/dialect/doris/src/main/antlr4/imports/doris/DDLStatement.g4
b/parser/sql/engine/dialect/doris/src/main/antlr4/imports/doris/DDLStatement.g4
index 943cbb02dd8..73db4baadb4 100644
---
a/parser/sql/engine/dialect/doris/src/main/antlr4/imports/doris/DDLStatement.g4
+++
b/parser/sql/engine/dialect/doris/src/main/antlr4/imports/doris/DDLStatement.g4
@@ -237,6 +237,10 @@ cancelBuildIndex
: CANCEL BUILD INDEX ON tableName jobIdList?
;
+cancelAlterTable
+ : CANCEL ALTER TABLE (COLUMN | MATERIALIZED VIEW | ROLLUP) FROM tableName
jobIdList?
+ ;
+
jobIdList
: LP_ jobId (COMMA_ jobId)* RP_
;
diff --git
a/parser/sql/engine/dialect/doris/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/DorisStatement.g4
b/parser/sql/engine/dialect/doris/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/DorisStatement.g4
index 30c21116d75..f84560d01ad 100644
---
a/parser/sql/engine/dialect/doris/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/DorisStatement.g4
+++
b/parser/sql/engine/dialect/doris/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/DorisStatement.g4
@@ -144,6 +144,7 @@ execute
| createRepository
| buildIndex
| cancelBuildIndex
+ | cancelAlterTable
| createFile
| dropFile
| sync
diff --git
a/parser/sql/engine/dialect/doris/src/main/java/org/apache/shardingsphere/sql/parser/engine/doris/visitor/statement/type/DorisDALStatementVisitor.java
b/parser/sql/engine/dialect/doris/src/main/java/org/apache/shardingsphere/sql/parser/engine/doris/visitor/statement/type/DorisDALStatementVisitor.java
index 024f1adccdc..9b523208c90 100644
---
a/parser/sql/engine/dialect/doris/src/main/java/org/apache/shardingsphere/sql/parser/engine/doris/visitor/statement/type/DorisDALStatementVisitor.java
+++
b/parser/sql/engine/dialect/doris/src/main/java/org/apache/shardingsphere/sql/parser/engine/doris/visitor/statement/type/DorisDALStatementVisitor.java
@@ -152,6 +152,7 @@ import
org.apache.shardingsphere.sql.parser.autogen.DorisStatementParser.ShowRou
import
org.apache.shardingsphere.sql.parser.autogen.DorisStatementParser.QualifiedJobNameContext;
import
org.apache.shardingsphere.sql.parser.autogen.DorisStatementParser.RuleNameContext;
import
org.apache.shardingsphere.sql.parser.autogen.DorisStatementParser.ShowBuildIndexContext;
+import
org.apache.shardingsphere.sql.parser.autogen.DorisStatementParser.ShowAlterTableContext;
import
org.apache.shardingsphere.sql.parser.engine.doris.visitor.statement.DorisStatementVisitor;
import
org.apache.shardingsphere.sql.parser.statement.core.segment.dal.CacheTableIndexSegment;
import
org.apache.shardingsphere.sql.parser.statement.core.segment.dal.CloneActionSegment;
@@ -216,6 +217,7 @@ import
org.apache.shardingsphere.sql.parser.statement.doris.dal.DorisShowRoutine
import
org.apache.shardingsphere.sql.parser.statement.doris.dal.DorisSyncStatement;
import
org.apache.shardingsphere.sql.parser.statement.core.segment.dal.RepositoryNameSegment;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.ShowBuildIndexStatement;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.ShowAlterTableStatement;
import
org.apache.shardingsphere.sql.parser.statement.doris.dal.show.DorisShowQueryStatsStatement;
import
org.apache.shardingsphere.sql.parser.statement.mysql.dal.MySQLCloneStatement;
import
org.apache.shardingsphere.sql.parser.statement.mysql.dal.MySQLCreateLoadableFunctionStatement;
@@ -1277,6 +1279,30 @@ public final class DorisDALStatementVisitor extends
DorisStatementVisitor implem
return result;
}
+ @Override
+ public ASTNode visitShowAlterTable(final ShowAlterTableContext ctx) {
+ ShowAlterTableStatement result = new
ShowAlterTableStatement(getDatabaseType());
+ if (null != ctx.COLUMN()) {
+ result.setAlterType("COLUMN");
+ } else if (null != ctx.ROLLUP()) {
+ result.setAlterType("ROLLUP");
+ }
+ if (null != ctx.fromDatabase()) {
+ FromDatabaseSegment fromDatabaseSegment = (FromDatabaseSegment)
visit(ctx.fromDatabase());
+ result.setDatabase(fromDatabaseSegment.getDatabase());
+ }
+ if (null != ctx.showWhereClause()) {
+ result.setWhere((WhereSegment) visit(ctx.showWhereClause()));
+ }
+ if (null != ctx.orderByClause()) {
+ result.setOrderBy((OrderBySegment) visit(ctx.orderByClause()));
+ }
+ if (null != ctx.limitClause()) {
+ result.setLimit((LimitSegment) visit(ctx.limitClause()));
+ }
+ return result;
+ }
+
private PropertiesSegment extractPropertiesSegment(final
PropertiesClauseContext ctx) {
PropertiesSegment result = new
PropertiesSegment(ctx.getStart().getStartIndex(), ctx.getStop().getStopIndex());
for (PropertyContext each : ctx.properties().property()) {
diff --git
a/parser/sql/engine/dialect/doris/src/main/java/org/apache/shardingsphere/sql/parser/engine/doris/visitor/statement/type/DorisDDLStatementVisitor.java
b/parser/sql/engine/dialect/doris/src/main/java/org/apache/shardingsphere/sql/parser/engine/doris/visitor/statement/type/DorisDDLStatementVisitor.java
index 34da1176ab9..a8b18799195 100644
---
a/parser/sql/engine/dialect/doris/src/main/java/org/apache/shardingsphere/sql/parser/engine/doris/visitor/statement/type/DorisDDLStatementVisitor.java
+++
b/parser/sql/engine/dialect/doris/src/main/java/org/apache/shardingsphere/sql/parser/engine/doris/visitor/statement/type/DorisDDLStatementVisitor.java
@@ -86,6 +86,7 @@ import
org.apache.shardingsphere.sql.parser.autogen.DorisStatementParser.DropTri
import
org.apache.shardingsphere.sql.parser.autogen.DorisStatementParser.DropViewContext;
import
org.apache.shardingsphere.sql.parser.autogen.DorisStatementParser.BuildIndexContext;
import
org.apache.shardingsphere.sql.parser.autogen.DorisStatementParser.CancelBuildIndexContext;
+import
org.apache.shardingsphere.sql.parser.autogen.DorisStatementParser.CancelAlterTableContext;
import
org.apache.shardingsphere.sql.parser.autogen.DorisStatementParser.ExecuteStmtContext;
import
org.apache.shardingsphere.sql.parser.autogen.DorisStatementParser.FieldDefinitionContext;
import
org.apache.shardingsphere.sql.parser.autogen.DorisStatementParser.FlowControlStatementContext;
@@ -189,6 +190,7 @@ import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.in
import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.index.DropIndexStatement;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.index.BuildIndexStatement;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.index.CancelBuildIndexStatement;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.alter.CancelAlterTableStatement;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.procedure.AlterProcedureStatement;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.procedure.CreateProcedureStatement;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.procedure.DropProcedureStatement;
@@ -923,6 +925,25 @@ public final class DorisDDLStatementVisitor extends
DorisStatementVisitor implem
return result;
}
+ @Override
+ public ASTNode visitCancelAlterTable(final CancelAlterTableContext ctx) {
+ CancelAlterTableStatement result = new
CancelAlterTableStatement(getDatabaseType());
+ result.setTable((SimpleTableSegment) visit(ctx.tableName()));
+ if (null != ctx.COLUMN()) {
+ result.setAlterType("COLUMN");
+ } else if (null != ctx.MATERIALIZED()) {
+ result.setAlterType("MATERIALIZED VIEW");
+ } else if (null != ctx.ROLLUP()) {
+ result.setAlterType("ROLLUP");
+ }
+ if (null != ctx.jobIdList()) {
+ for (JobIdContext each : ctx.jobIdList().jobId()) {
+ result.getJobIds().add(each.getText());
+ }
+ }
+ return result;
+ }
+
@Override
public ASTNode visitRenameRollup(final RenameRollupContext ctx) {
RollupSegment oldRollupSegment = new
RollupSegment(ctx.oldRollupName.getStart().getStartIndex(),
ctx.oldRollupName.getStop().getStopIndex(),
diff --git
a/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/statement/type/dal/ShowAlterTableStatement.java
b/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/statement/type/dal/ShowAlterTableStatement.java
new file mode 100644
index 00000000000..4ec3aa95cf0
--- /dev/null
+++
b/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/statement/type/dal/ShowAlterTableStatement.java
@@ -0,0 +1,95 @@
+/*
+ * 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.statement.core.statement.type.dal;
+
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
+import
org.apache.shardingsphere.sql.parser.statement.core.segment.dml.order.OrderBySegment;
+import
org.apache.shardingsphere.sql.parser.statement.core.segment.dml.pagination.limit.LimitSegment;
+import
org.apache.shardingsphere.sql.parser.statement.core.segment.dml.predicate.WhereSegment;
+import
org.apache.shardingsphere.sql.parser.statement.core.segment.generic.DatabaseSegment;
+
+import java.util.Optional;
+
+/**
+ * Show alter table statement.
+ */
+@Getter
+@Setter
+public final class ShowAlterTableStatement extends DALStatement {
+
+ private String alterType;
+
+ private DatabaseSegment database;
+
+ private WhereSegment where;
+
+ private OrderBySegment orderBy;
+
+ private LimitSegment limit;
+
+ public ShowAlterTableStatement(final DatabaseType databaseType) {
+ super(databaseType);
+ }
+
+ /**
+ * Get alter type.
+ *
+ * @return alter type
+ */
+ public Optional<String> getAlterType() {
+ return Optional.ofNullable(alterType);
+ }
+
+ /**
+ * Get database.
+ *
+ * @return database
+ */
+ public Optional<DatabaseSegment> getDatabase() {
+ return Optional.ofNullable(database);
+ }
+
+ /**
+ * Get where segment.
+ *
+ * @return where segment
+ */
+ public Optional<WhereSegment> getWhere() {
+ return Optional.ofNullable(where);
+ }
+
+ /**
+ * Get order by.
+ *
+ * @return order by
+ */
+ public Optional<OrderBySegment> getOrderBy() {
+ return Optional.ofNullable(orderBy);
+ }
+
+ /**
+ * Get limit.
+ *
+ * @return limit
+ */
+ public Optional<LimitSegment> getLimit() {
+ return Optional.ofNullable(limit);
+ }
+}
diff --git
a/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/statement/type/ddl/alter/CancelAlterTableStatement.java
b/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/statement/type/ddl/alter/CancelAlterTableStatement.java
new file mode 100644
index 00000000000..d244288d42b
--- /dev/null
+++
b/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/statement/type/ddl/alter/CancelAlterTableStatement.java
@@ -0,0 +1,54 @@
+/*
+ * 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.statement.core.statement.type.ddl.alter;
+
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
+import
org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.SQLStatementAttributes;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.TableSQLStatementAttribute;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.DDLStatement;
+
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * Cancel alter table statement.
+ */
+@Getter
+@Setter
+public final class CancelAlterTableStatement extends DDLStatement {
+
+ private SimpleTableSegment table;
+
+ private String alterType;
+
+ private final List<String> jobIds = new LinkedList<>();
+
+ private SQLStatementAttributes attributes;
+
+ public CancelAlterTableStatement(final DatabaseType databaseType) {
+ super(databaseType);
+ }
+
+ @Override
+ public void buildAttributes() {
+ attributes = new SQLStatementAttributes(new
TableSQLStatementAttribute(table));
+ }
+}
diff --git
a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dal/standard/StandardDALStatementAssert.java
b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dal/standard/StandardDALStatementAssert.java
index 95237ca04c9..90167a8ed1f 100644
---
a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dal/standard/StandardDALStatementAssert.java
+++
b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dal/standard/StandardDALStatementAssert.java
@@ -25,6 +25,7 @@ import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.Ex
import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.SetStatement;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.ShowStatement;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.ShowBuildIndexStatement;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.ShowAlterTableStatement;
import
org.apache.shardingsphere.sql.parser.statement.doris.dal.DorisAlterSqlBlockRuleStatement;
import
org.apache.shardingsphere.sql.parser.statement.doris.dal.DorisDropSqlBlockRuleStatement;
import
org.apache.shardingsphere.sql.parser.statement.doris.dal.DorisShowSqlBlockRuleStatement;
@@ -36,6 +37,7 @@ import
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.d
import
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.standard.type.SetParameterStatementAssert;
import
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.standard.type.ShowStatementAssert;
import
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.standard.type.ShowBuildIndexStatementAssert;
+import
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.standard.type.ShowAlterTableStatementAssert;
import
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.dialect.doris.type.DorisAlterSqlBlockRuleStatementAssert;
import
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.dialect.doris.type.DorisDropSqlBlockRuleStatementAssert;
import
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.dialect.doris.type.DorisShowSqlBlockRuleStatementAssert;
@@ -48,6 +50,7 @@ import
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.s
import
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.dal.dialect.doris.DorisShowRoutineLoadTaskStatementTestCase;
import
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.dal.dialect.doris.DorisShowRoutineLoadStatementTestCase;
import
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.dal.ShowBuildIndexStatementTestCase;
+import
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.dal.ShowAlterTableStatementTestCase;
import
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.dal.standard.EmptyStatementTestCase;
import
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.dal.standard.ExplainStatementTestCase;
import
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.dal.standard.SetParameterStatementTestCase;
@@ -87,6 +90,8 @@ public final class StandardDALStatementAssert {
DorisShowRoutineLoadTaskStatementAssert.assertIs(assertContext,
(DorisShowRoutineLoadTaskStatement) actual,
(DorisShowRoutineLoadTaskStatementTestCase) expected);
} else if (actual instanceof DorisShowRoutineLoadStatement) {
DorisShowRoutineLoadStatementAssert.assertIs(assertContext,
(DorisShowRoutineLoadStatement) actual, (DorisShowRoutineLoadStatementTestCase)
expected);
+ } else if (actual instanceof ShowAlterTableStatement) {
+ ShowAlterTableStatementAssert.assertIs(assertContext,
(ShowAlterTableStatement) actual, (ShowAlterTableStatementTestCase) expected);
}
}
}
diff --git
a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dal/standard/type/ShowAlterTableStatementAssert.java
b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dal/standard/type/ShowAlterTableStatementAssert.java
new file mode 100644
index 00000000000..0554d51767b
--- /dev/null
+++
b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dal/standard/type/ShowAlterTableStatementAssert.java
@@ -0,0 +1,98 @@
+/*
+ * 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.it.sql.parser.internal.asserts.statement.dal.standard.type;
+
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.ShowAlterTableStatement;
+import
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
+import
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.database.DatabaseAssert;
+import
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.limit.LimitClauseAssert;
+import
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.orderby.OrderByClauseAssert;
+import
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.where.WhereClauseAssert;
+import
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.dal.ShowAlterTableStatementTestCase;
+import org.hamcrest.MatcherAssert;
+import org.hamcrest.Matchers;
+import org.junit.jupiter.api.Assertions;
+
+/**
+ * Show alter table statement assert.
+ */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class ShowAlterTableStatementAssert {
+
+ /**
+ * Assert show alter table statement is correct with expected parser
result.
+ *
+ * @param assertContext assert context
+ * @param actual actual show alter table statement
+ * @param expected expected show alter table statement test case
+ */
+ public static void assertIs(final SQLCaseAssertContext assertContext,
final ShowAlterTableStatement actual, final ShowAlterTableStatementTestCase
expected) {
+ assertAlterType(assertContext, actual, expected);
+ assertDatabase(assertContext, actual, expected);
+ assertWhere(assertContext, actual, expected);
+ assertOrderBy(assertContext, actual, expected);
+ assertLimit(assertContext, actual, expected);
+ }
+
+ private static void assertAlterType(final SQLCaseAssertContext
assertContext, final ShowAlterTableStatement actual, final
ShowAlterTableStatementTestCase expected) {
+ if (null != expected.getAlterType()) {
+ Assertions.assertNotNull(actual.getAlterType().orElse(null),
assertContext.getText("Actual alter type should exist."));
+ MatcherAssert.assertThat(assertContext.getText("Alter type
assertion error: "), actual.getAlterType().get(),
Matchers.is(expected.getAlterType()));
+ } else {
+ Assertions.assertNull(actual.getAlterType().orElse(null),
assertContext.getText("Actual alter type should not exist."));
+ }
+ }
+
+ private static void assertDatabase(final SQLCaseAssertContext
assertContext, final ShowAlterTableStatement actual, final
ShowAlterTableStatementTestCase expected) {
+ if (null != expected.getDatabase()) {
+ Assertions.assertNotNull(actual.getDatabase().orElse(null),
assertContext.getText("Actual database should exist."));
+ DatabaseAssert.assertIs(assertContext, actual.getDatabase().get(),
expected.getDatabase());
+ } else {
+ Assertions.assertNull(actual.getDatabase().orElse(null),
assertContext.getText("Actual database should not exist."));
+ }
+ }
+
+ private static void assertWhere(final SQLCaseAssertContext assertContext,
final ShowAlterTableStatement actual, final ShowAlterTableStatementTestCase
expected) {
+ if (null != expected.getWhere()) {
+ Assertions.assertNotNull(actual.getWhere().orElse(null),
assertContext.getText("Actual where segment should exist."));
+ WhereClauseAssert.assertIs(assertContext, actual.getWhere().get(),
expected.getWhere());
+ } else {
+ Assertions.assertNull(actual.getWhere().orElse(null),
assertContext.getText("Actual where segment should not exist."));
+ }
+ }
+
+ private static void assertOrderBy(final SQLCaseAssertContext
assertContext, final ShowAlterTableStatement actual, final
ShowAlterTableStatementTestCase expected) {
+ if (null != expected.getOrderBy()) {
+ Assertions.assertNotNull(actual.getOrderBy().orElse(null),
assertContext.getText("Actual order by segment should exist."));
+ OrderByClauseAssert.assertIs(assertContext,
actual.getOrderBy().get(), expected.getOrderBy());
+ } else {
+ Assertions.assertNull(actual.getOrderBy().orElse(null),
assertContext.getText("Actual order by segment should not exist."));
+ }
+ }
+
+ private static void assertLimit(final SQLCaseAssertContext assertContext,
final ShowAlterTableStatement actual, final ShowAlterTableStatementTestCase
expected) {
+ if (null != expected.getLimit()) {
+ Assertions.assertNotNull(actual.getLimit().orElse(null),
assertContext.getText("Actual limit segment should exist."));
+ LimitClauseAssert.assertRowCount(assertContext,
actual.getLimit().get().getRowCount().orElse(null),
expected.getLimit().getRowCount());
+ } else {
+ Assertions.assertNull(actual.getLimit().orElse(null),
assertContext.getText("Actual limit segment should not exist."));
+ }
+ }
+}
diff --git
a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ddl/standard/StandardDDLStatementAssert.java
b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ddl/standard/StandardDDLStatementAssert.java
index f68236c06af..0c925a8fe6a 100644
---
a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ddl/standard/StandardDDLStatementAssert.java
+++
b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ddl/standard/StandardDDLStatementAssert.java
@@ -33,6 +33,7 @@ import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.in
import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.index.DropIndexStatement;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.index.BuildIndexStatement;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.index.CancelBuildIndexStatement;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.alter.CancelAlterTableStatement;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.procedure.CreateProcedureStatement;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.sequence.CreateSequenceStatement;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.synonym.AlterSynonymStatement;
@@ -76,6 +77,7 @@ import
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.d
import
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ddl.standard.type.AlterDatabaseStatementAssert;
import
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ddl.standard.type.BuildIndexStatementAssert;
import
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ddl.standard.type.CancelBuildIndexStatementAssert;
+import
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ddl.standard.type.CancelAlterTableStatementAssert;
import
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.SQLParserTestCase;
import
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.standard.CloseStatementTestCase;
import
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.standard.CommentStatementTestCase;
@@ -90,6 +92,7 @@ import
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.s
import
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.standard.index.DropIndexStatementTestCase;
import
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.standard.index.BuildIndexStatementTestCase;
import
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.standard.index.CancelBuildIndexStatementTestCase;
+import
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.standard.alter.CancelAlterTableStatementTestCase;
import
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.standard.sequence.CreateSequenceStatementTestCase;
import
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.standard.synonym.AlterSynonymStatementTestCase;
import
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.standard.table.AlterTableStatementTestCase;
@@ -175,6 +178,8 @@ public final class StandardDDLStatementAssert {
CreateFileStatementAssert.assertIs(assertContext,
(CreateFileStatement) actual, (CreateFileStatementTestCase) expected);
} else if (actual instanceof DropFileStatement) {
DropFileStatementAssert.assertIs(assertContext,
(DropFileStatement) actual, (DropFileStatementTestCase) expected);
+ } else if (actual instanceof CancelAlterTableStatement) {
+ CancelAlterTableStatementAssert.assertIs(assertContext,
(CancelAlterTableStatement) actual, (CancelAlterTableStatementTestCase)
expected);
}
}
}
diff --git
a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ddl/standard/type/CancelAlterTableStatementAssert.java
b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ddl/standard/type/CancelAlterTableStatementAssert.java
new file mode 100644
index 00000000000..412dbdda00e
--- /dev/null
+++
b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ddl/standard/type/CancelAlterTableStatementAssert.java
@@ -0,0 +1,74 @@
+/*
+ * 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.it.sql.parser.internal.asserts.statement.ddl.standard.type;
+
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+import
org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.alter.CancelAlterTableStatement;
+import
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
+import
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.table.TableAssert;
+import
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.standard.alter.CancelAlterTableStatementTestCase;
+import org.hamcrest.MatcherAssert;
+import org.hamcrest.Matchers;
+import org.junit.jupiter.api.Assertions;
+
+/**
+ * Cancel alter table statement assert.
+ */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class CancelAlterTableStatementAssert {
+
+ /**
+ * Assert cancel alter table statement is correct with expected parser
result.
+ *
+ * @param assertContext assert context
+ * @param actual actual cancel alter table statement
+ * @param expected expected cancel alter table statement test case
+ */
+ public static void assertIs(final SQLCaseAssertContext assertContext,
final CancelAlterTableStatement actual, final CancelAlterTableStatementTestCase
expected) {
+ assertTable(assertContext, actual, expected);
+ assertAlterType(assertContext, actual, expected);
+ assertJobIds(assertContext, actual, expected);
+ }
+
+ private static void assertTable(final SQLCaseAssertContext assertContext,
final CancelAlterTableStatement actual, final CancelAlterTableStatementTestCase
expected) {
+ if (null == expected.getTable()) {
+ Assertions.assertNull(actual.getTable(),
assertContext.getText("Actual table segment should not exist."));
+ } else {
+ Assertions.assertNotNull(actual.getTable(),
assertContext.getText("Actual table segment should exist."));
+ TableAssert.assertIs(assertContext, actual.getTable(),
expected.getTable());
+ }
+ }
+
+ private static void assertAlterType(final SQLCaseAssertContext
assertContext, final CancelAlterTableStatement actual, final
CancelAlterTableStatementTestCase expected) {
+ Assertions.assertNotNull(expected.getAlterType(),
assertContext.getText("Expected alter type should exist."));
+ Assertions.assertNotNull(actual.getAlterType(),
assertContext.getText("Actual alter type should exist."));
+ MatcherAssert.assertThat(assertContext.getText("Alter type assertion
error: "), actual.getAlterType(), Matchers.is(expected.getAlterType()));
+ }
+
+ private static void assertJobIds(final SQLCaseAssertContext assertContext,
final CancelAlterTableStatement actual, final CancelAlterTableStatementTestCase
expected) {
+ if (null == expected.getJobIds() || expected.getJobIds().isEmpty()) {
+ Assertions.assertTrue(actual.getJobIds().isEmpty(),
assertContext.getText("Actual job IDs should not exist."));
+ } else {
+ MatcherAssert.assertThat(assertContext.getText("Job IDs size
assertion error: "), actual.getJobIds().size(),
Matchers.is(expected.getJobIds().size()));
+ for (int i = 0; i < expected.getJobIds().size(); i++) {
+
MatcherAssert.assertThat(assertContext.getText(String.format("Job ID assertion
error at index %d: ", i)), actual.getJobIds().get(i),
Matchers.is(expected.getJobIds().get(i)));
+ }
+ }
+ }
+}
diff --git
a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/RootSQLParserTestCases.java
b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/RootSQLParserTestCases.java
index c6713e7a211..5b109ea050b 100644
---
a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/RootSQLParserTestCases.java
+++
b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/RootSQLParserTestCases.java
@@ -288,9 +288,11 @@ import
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.s
import
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.standard.index.DropIndexStatementTestCase;
import
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.standard.index.CancelBuildIndexStatementTestCase;
import
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.standard.index.BuildIndexStatementTestCase;
+import
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.standard.alter.CancelAlterTableStatementTestCase;
import
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.standard.macro.CreateMacroStatementTestCase;
import
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.standard.macro.DropMacroStatementTestCase;
import
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.dal.ShowBuildIndexStatementTestCase;
+import
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.dal.ShowAlterTableStatementTestCase;
import
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.standard.operator.AlterOperatorStatementTestCase;
import
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.standard.operator.CreateOperatorStatementTestCase;
import
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.standard.operator.DropOperatorStatementTestCase;
@@ -574,12 +576,18 @@ public final class RootSQLParserTestCases {
@XmlElement(name = "show-build-index")
private final List<ShowBuildIndexStatementTestCase>
showBuildIndexTestCases = new LinkedList<>();
+ @XmlElement(name = "show-alter-table")
+ private final List<ShowAlterTableStatementTestCase>
showAlterTableTestCases = new LinkedList<>();
+
@XmlElement(name = "build-index")
private final List<BuildIndexStatementTestCase> buildIndexTestCases = new
LinkedList<>();
@XmlElement(name = "cancel-build-index")
private final List<CancelBuildIndexStatementTestCase>
cancelBuildIndexStatementTestCases = new LinkedList<>();
+ @XmlElement(name = "cancel-alter-table")
+ private final List<CancelAlterTableStatementTestCase>
cancelAlterTableStatementTestCases = new LinkedList<>();
+
@XmlElement(name = "alter-sql-block-rule")
private final List<DorisAlterSqlBlockRuleStatementTestCase>
alterSqlBlockRuleTestCases = new LinkedList<>();
diff --git
a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/dal/ShowAlterTableStatementTestCase.java
b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/dal/ShowAlterTableStatementTestCase.java
new file mode 100644
index 00000000000..ecc0bf1f677
--- /dev/null
+++
b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/dal/ShowAlterTableStatementTestCase.java
@@ -0,0 +1,52 @@
+/*
+ * 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.it.sql.parser.internal.cases.parser.jaxb.statement.dal;
+
+import lombok.Getter;
+import lombok.Setter;
+import
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.segment.impl.database.ExpectedDatabase;
+import
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.segment.impl.limit.ExpectedLimitClause;
+import
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.segment.impl.orderby.ExpectedOrderByClause;
+import
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.segment.impl.where.ExpectedWhereClause;
+import
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.SQLParserTestCase;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+
+/**
+ * Show alter table statement test case.
+ */
+@Getter
+@Setter
+public final class ShowAlterTableStatementTestCase extends SQLParserTestCase {
+
+ @XmlAttribute(name = "alter-type")
+ private String alterType;
+
+ @XmlElement
+ private ExpectedDatabase database;
+
+ @XmlElement(name = "where")
+ private ExpectedWhereClause where;
+
+ @XmlElement(name = "order-by")
+ private ExpectedOrderByClause orderBy;
+
+ @XmlElement(name = "limit")
+ private ExpectedLimitClause limit;
+}
diff --git
a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/ddl/standard/alter/CancelAlterTableStatementTestCase.java
b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/ddl/standard/alter/CancelAlterTableStatementTestCase.java
new file mode 100644
index 00000000000..8544b89ba27
--- /dev/null
+++
b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/ddl/standard/alter/CancelAlterTableStatementTestCase.java
@@ -0,0 +1,45 @@
+/*
+ * 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.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.standard.alter;
+
+import lombok.Getter;
+import lombok.Setter;
+import
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.SQLParserTestCase;
+import
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.segment.impl.table.ExpectedTable;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * Cancel alter table statement test case.
+ */
+@Getter
+@Setter
+public final class CancelAlterTableStatementTestCase extends SQLParserTestCase
{
+
+ @XmlElement
+ private ExpectedTable table;
+
+ @XmlAttribute(name = "alter-type")
+ private String alterType;
+
+ @XmlElement(name = "job-id")
+ private final List<String> jobIds = new LinkedList<>();
+}
diff --git a/test/it/parser/src/main/resources/case/dal/show-alter-table.xml
b/test/it/parser/src/main/resources/case/dal/show-alter-table.xml
new file mode 100644
index 00000000000..d4225d79666
--- /dev/null
+++ b/test/it/parser/src/main/resources/case/dal/show-alter-table.xml
@@ -0,0 +1,90 @@
+<?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>
+ <show-alter-table sql-case-id="show_alter_table_column_simple"
alter-type="COLUMN" />
+
+ <show-alter-table sql-case-id="show_alter_table_rollup_simple"
alter-type="ROLLUP" />
+
+ <show-alter-table sql-case-id="show_alter_table_simple" />
+
+ <show-alter-table sql-case-id="show_alter_table_column_with_database"
alter-type="COLUMN">
+ <database name="db1" start-index="29" stop-index="31" />
+ </show-alter-table>
+
+ <show-alter-table sql-case-id="show_alter_table_column_with_where"
alter-type="COLUMN">
+ <where start-index="24" stop-index="49">
+ <expr>
+ <binary-operation-expression start-index="30" stop-index="49">
+ <left>
+ <column name="TableName" start-index="30"
stop-index="38" />
+ </left>
+ <operator>=</operator>
+ <right>
+ <literal-expression value="table1"
start-delimiter=""" end-delimiter=""" start-index="42"
stop-index="49" />
+ </right>
+ </binary-operation-expression>
+ </expr>
+ </where>
+ </show-alter-table>
+
+ <show-alter-table sql-case-id="show_alter_table_column_with_order_by"
alter-type="COLUMN">
+ <where start-index="24" stop-index="49">
+ <expr>
+ <binary-operation-expression start-index="30" stop-index="49">
+ <left>
+ <column name="TableName" start-index="30"
stop-index="38" />
+ </left>
+ <operator>=</operator>
+ <right>
+ <literal-expression value="table1"
start-delimiter=""" end-delimiter=""" start-index="42"
stop-index="49" />
+ </right>
+ </binary-operation-expression>
+ </expr>
+ </where>
+ <order-by>
+ <column-item name="CreateTime" order-direction="DESC"
start-index="60" stop-index="69" />
+ </order-by>
+ </show-alter-table>
+
+ <show-alter-table sql-case-id="show_alter_table_column_with_limit"
alter-type="COLUMN">
+ <where start-index="24" stop-index="49">
+ <expr>
+ <binary-operation-expression start-index="30" stop-index="49">
+ <left>
+ <column name="TableName" start-index="30"
stop-index="38" />
+ </left>
+ <operator>=</operator>
+ <right>
+ <literal-expression value="table1"
start-delimiter=""" end-delimiter=""" start-index="42"
stop-index="49" />
+ </right>
+ </binary-operation-expression>
+ </expr>
+ </where>
+ <order-by>
+ <column-item name="CreateTime" order-direction="DESC"
start-index="60" stop-index="69" />
+ </order-by>
+ <limit start-index="82" stop-index="82">
+ <row-count value="1" start-index="82" stop-index="82" />
+ </limit>
+ </show-alter-table>
+
+ <show-alter-table sql-case-id="show_alter_table_rollup_with_database"
alter-type="ROLLUP">
+ <database name="example_db" start-index="29" stop-index="38" />
+ </show-alter-table>
+</sql-parser-test-cases>
diff --git a/test/it/parser/src/main/resources/case/ddl/cancel-alter-table.xml
b/test/it/parser/src/main/resources/case/ddl/cancel-alter-table.xml
new file mode 100644
index 00000000000..b3575ee4671
--- /dev/null
+++ b/test/it/parser/src/main/resources/case/ddl/cancel-alter-table.xml
@@ -0,0 +1,70 @@
+<?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>
+ <cancel-alter-table sql-case-id="cancel_alter_table_column_without_jobs"
alter-type="COLUMN">
+ <table>
+ <simple-table name="table_name" start-index="31" stop-index="40" />
+ </table>
+ </cancel-alter-table>
+
+ <cancel-alter-table sql-case-id="cancel_alter_table_column_with_jobs"
alter-type="COLUMN">
+ <table>
+ <simple-table name="table_name" start-index="31" stop-index="40" />
+ </table>
+ <job-id>10001</job-id>
+ <job-id>10002</job-id>
+ </cancel-alter-table>
+
+ <cancel-alter-table sql-case-id="cancel_alter_table_rollup_without_jobs"
alter-type="ROLLUP">
+ <table>
+ <simple-table name="table_name" start-index="31" stop-index="40" />
+ </table>
+ </cancel-alter-table>
+
+ <cancel-alter-table sql-case-id="cancel_alter_table_rollup_with_jobs"
alter-type="ROLLUP">
+ <table>
+ <simple-table name="table_name" start-index="31" stop-index="40" />
+ </table>
+ <job-id>20001</job-id>
+ <job-id>20002</job-id>
+ <job-id>20003</job-id>
+ </cancel-alter-table>
+
+ <cancel-alter-table
sql-case-id="cancel_alter_table_materialized_view_without_jobs"
alter-type="MATERIALIZED VIEW">
+ <table>
+ <simple-table name="table_name" start-index="42" stop-index="51" />
+ </table>
+ </cancel-alter-table>
+
+ <cancel-alter-table
sql-case-id="cancel_alter_table_materialized_view_with_jobs"
alter-type="MATERIALIZED VIEW">
+ <table>
+ <simple-table name="table_name" start-index="42" stop-index="51" />
+ </table>
+ <job-id>30001</job-id>
+ </cancel-alter-table>
+
+ <cancel-alter-table sql-case-id="cancel_alter_table_rollup_db_table"
alter-type="ROLLUP">
+ <table>
+ <simple-table name="table_name" start-index="31" stop-index="48">
+ <owner name="db_name" start-index="31" stop-index="37" />
+ </simple-table>
+ </table>
+ <job-id>40001</job-id>
+ </cancel-alter-table>
+</sql-parser-test-cases>
diff --git
a/test/it/parser/src/main/resources/sql/supported/dal/show-alter-table.xml
b/test/it/parser/src/main/resources/sql/supported/dal/show-alter-table.xml
new file mode 100644
index 00000000000..2f45a3a31de
--- /dev/null
+++ b/test/it/parser/src/main/resources/sql/supported/dal/show-alter-table.xml
@@ -0,0 +1,28 @@
+<?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="show_alter_table_column_simple" value="SHOW ALTER TABLE
COLUMN" db-types="Doris" />
+ <sql-case id="show_alter_table_rollup_simple" value="SHOW ALTER TABLE
ROLLUP" db-types="Doris" />
+ <sql-case id="show_alter_table_simple" value="SHOW ALTER TABLE"
db-types="Doris" />
+ <sql-case id="show_alter_table_column_with_database" value="SHOW ALTER
TABLE COLUMN FROM db1" db-types="Doris" />
+ <sql-case id="show_alter_table_column_with_where" value="SHOW ALTER TABLE
COLUMN WHERE TableName = "table1"" db-types="Doris" />
+ <sql-case id="show_alter_table_column_with_order_by" value="SHOW ALTER
TABLE COLUMN WHERE TableName = "table1" ORDER BY CreateTime DESC"
db-types="Doris" />
+ <sql-case id="show_alter_table_column_with_limit" value="SHOW ALTER TABLE
COLUMN WHERE TableName = "table1" ORDER BY CreateTime DESC LIMIT 1"
db-types="Doris" />
+ <sql-case id="show_alter_table_rollup_with_database" value="SHOW ALTER
TABLE ROLLUP FROM example_db" db-types="Doris" />
+</sql-cases>
diff --git
a/test/it/parser/src/main/resources/sql/supported/ddl/cancel-alter-table.xml
b/test/it/parser/src/main/resources/sql/supported/ddl/cancel-alter-table.xml
new file mode 100644
index 00000000000..cbe31465542
--- /dev/null
+++ b/test/it/parser/src/main/resources/sql/supported/ddl/cancel-alter-table.xml
@@ -0,0 +1,27 @@
+<?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="cancel_alter_table_column_without_jobs" value="CANCEL ALTER
TABLE COLUMN FROM table_name" db-types="Doris" />
+ <sql-case id="cancel_alter_table_column_with_jobs" value="CANCEL ALTER
TABLE COLUMN FROM table_name (10001, 10002)" db-types="Doris" />
+ <sql-case id="cancel_alter_table_rollup_without_jobs" value="CANCEL ALTER
TABLE ROLLUP FROM table_name" db-types="Doris" />
+ <sql-case id="cancel_alter_table_rollup_with_jobs" value="CANCEL ALTER
TABLE ROLLUP FROM table_name (20001, 20002, 20003)" db-types="Doris" />
+ <sql-case id="cancel_alter_table_materialized_view_without_jobs"
value="CANCEL ALTER TABLE MATERIALIZED VIEW FROM table_name" db-types="Doris" />
+ <sql-case id="cancel_alter_table_materialized_view_with_jobs"
value="CANCEL ALTER TABLE MATERIALIZED VIEW FROM table_name (30001)"
db-types="Doris" />
+ <sql-case id="cancel_alter_table_rollup_db_table" value="CANCEL ALTER
TABLE ROLLUP FROM db_name.table_name (40001);" db-types="Doris" />
+</sql-cases>