diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowTabletIdCommand.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowTabletIdCommand.java index 15d8323781673c..a311ad5404ff24 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowTabletIdCommand.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowTabletIdCommand.java @@ -46,7 +46,6 @@ import org.apache.doris.statistics.query.QueryStatsUtil; import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Strings; import com.google.common.collect.Lists; import java.util.List; @@ -56,7 +55,6 @@ */ public class ShowTabletIdCommand extends ShowCommand { private final long tabletId; - private String dbName; /** * constructor @@ -97,11 +95,6 @@ protected void validate(ConnectContext ctx) throws AnalysisException { if (!Env.getCurrentEnv().getAccessManager().checkGlobalPriv(ConnectContext.get(), PrivPredicate.ADMIN)) { ErrorReport.reportAnalysisException(ErrorCode.ERR_SPECIFIC_ACCESS_DENIED_ERROR, "SHOW TABLET"); } - - dbName = ctx.getDatabase(); - if (Strings.isNullOrEmpty(dbName)) { - ErrorReport.reportAnalysisException(ErrorCode.ERR_NO_DB_ERROR); - } } private ShowResultSet handleShowTabletId() { diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/commands/ShowTabletIdCommandTest.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/commands/ShowTabletIdCommandTest.java index d3a3ad0f7fda59..9d3c335721fb0c 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/commands/ShowTabletIdCommandTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/commands/ShowTabletIdCommandTest.java @@ -85,9 +85,9 @@ void noGlobalPriv() { } @Test - void dbIsEmpty() { + void noDatabaseSelected() { runBefore("", true); ShowTabletIdCommand command = new ShowTabletIdCommand(CatalogMocker.TEST_TBL_ID); - Assertions.assertThrows(AnalysisException.class, () -> command.validate(ctx)); + Assertions.assertDoesNotThrow(() -> command.validate(ctx)); } } diff --git a/regression-test/suites/show_p0/test_show_tablet.groovy b/regression-test/suites/show_p0/test_show_tablet.groovy index 024e90fdd198bf..abe54d7e93ffa6 100644 --- a/regression-test/suites/show_p0/test_show_tablet.groovy +++ b/regression-test/suites/show_p0/test_show_tablet.groovy @@ -27,6 +27,12 @@ suite("test_show_tablet") { );""" def res = sql """ SHOW TABLETS FROM show_tablets_test_t """ + def noDbJdbcUrl = context.config.jdbcUrl.replaceFirst(/(jdbc:mysql:\/\/[^\/]+\/)[^?]*/, '$1') + connect(context.config.jdbcUser, context.config.jdbcPassword, noDbJdbcUrl) { + def tabletId = res[0][0] + def tabletRes = sql """ SHOW TABLET ${tabletId} """ + assertTrue(tabletRes.size() == 1) + } if (res.size() == 5) { // replication num == 1 res = sql """SHOW TABLETS FROM show_tablets_test_t limit 5, 1;""" @@ -53,4 +59,4 @@ suite("test_show_tablet") { } else { assertTrue(1 == 2) } -} \ No newline at end of file +}