Skip to content

Commit

Permalink
[BugFix] Fix show alter table optimize with filter (#34897)
Browse files Browse the repository at this point in the history
Signed-off-by: meegoo <meegoo.sr@gmail.com>
  • Loading branch information
meegoo authored Nov 15, 2023
1 parent 04a0be7 commit b5848a2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fe/fe-core/src/main/java/com/starrocks/qe/ShowExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
import com.starrocks.common.proc.FrontendsProcNode;
import com.starrocks.common.proc.LakeTabletsProcDir;
import com.starrocks.common.proc.LocalTabletsProcDir;
import com.starrocks.common.proc.OptimizeProcDir;
import com.starrocks.common.proc.PartitionsProcDir;
import com.starrocks.common.proc.ProcNodeInterface;
import com.starrocks.common.proc.SchemaChangeProcDir;
Expand Down Expand Up @@ -1637,6 +1638,9 @@ private void handleShowAlter() throws AnalysisException {
if (procNodeI instanceof SchemaChangeProcDir) {
rows = ((SchemaChangeProcDir) procNodeI).fetchResultByFilter(showStmt.getFilterMap(),
showStmt.getOrderPairs(), showStmt.getLimitElement()).getRows();
} else if (procNodeI instanceof OptimizeProcDir) {
rows = ((OptimizeProcDir) procNodeI).fetchResultByFilter(showStmt.getFilterMap(),
showStmt.getOrderPairs(), showStmt.getLimitElement()).getRows();
} else {
rows = procNodeI.fetchResult().getRows();
}
Expand Down
10 changes: 10 additions & 0 deletions fe/fe-core/src/test/java/com/starrocks/qe/ShowExecutorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
import com.starrocks.common.UserException;
import com.starrocks.common.jmockit.Deencapsulation;
import com.starrocks.common.proc.ComputeNodeProcDir;
import com.starrocks.common.proc.OptimizeProcDir;
import com.starrocks.datacache.DataCacheMgr;
import com.starrocks.lake.StarOSAgent;
import com.starrocks.mysql.MysqlCommand;
Expand All @@ -82,6 +83,7 @@
import com.starrocks.sql.ast.DescribeStmt;
import com.starrocks.sql.ast.QualifiedName;
import com.starrocks.sql.ast.SetType;
import com.starrocks.sql.ast.ShowAlterStmt;
import com.starrocks.sql.ast.ShowAuthorStmt;
import com.starrocks.sql.ast.ShowBackendsStmt;
import com.starrocks.sql.ast.ShowBasicStatsMetaStmt;
Expand Down Expand Up @@ -1025,6 +1027,14 @@ public void testShowRoutineLoadNonExisted() throws AnalysisException, DdlExcepti
Assert.assertThrows(AnalysisException.class, () -> executor.execute());
}

@Test
public void testShowAlterTable() throws AnalysisException, DdlException {
ShowAlterStmt stmt = new ShowAlterStmt(ShowAlterStmt.AlterType.OPTIMIZE, "testDb", null, null, null);
stmt.setNode(new OptimizeProcDir(globalStateMgr.getSchemaChangeHandler(), globalStateMgr.getDb("testDb")));
ShowExecutor executor = new ShowExecutor(ctx, stmt);
executor.execute();
}

@Test
public void testShowCreateExternalCatalogTable() throws DdlException, AnalysisException {
new MockUp<MetadataMgr>() {
Expand Down

0 comments on commit b5848a2

Please sign in to comment.