Skip to content

Commit

Permalink
[BugFix] Fix show keys from support external catalog (StarRocks#52977)
Browse files Browse the repository at this point in the history
Signed-off-by: Astralidea <[email protected]>
  • Loading branch information
Astralidea authored Nov 20, 2024
1 parent 10dcbd7 commit c38a677
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
6 changes: 5 additions & 1 deletion fe/fe-core/src/main/java/com/starrocks/qe/ShowExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -2177,7 +2177,11 @@ public ShowResultSet visitShowDynamicPartitionStatement(ShowDynamicPartitionStmt
@Override
public ShowResultSet visitShowIndexStatement(ShowIndexStmt statement, ConnectContext context) {
List<List<String>> rows = Lists.newArrayList();
Database db = context.getGlobalStateMgr().getLocalMetastore().getDb(statement.getDbName());
String catalogName = statement.getTableName().getCatalog();
if (catalogName == null) {
catalogName = context.getCurrentCatalog();
}
Database db = GlobalStateMgr.getCurrentState().getMetadataMgr().getDb(catalogName, statement.getDbName());
MetaUtils.checkDbNullAndReport(db, statement.getDbName());
Table table = MetaUtils.getSessionAwareTable(context, db, statement.getTableName());
if (table == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
import com.starrocks.sql.ast.ShowDbStmt;
import com.starrocks.sql.ast.ShowEnginesStmt;
import com.starrocks.sql.ast.ShowGrantsStmt;
import com.starrocks.sql.ast.ShowIndexStmt;
import com.starrocks.sql.ast.ShowMaterializedViewsStmt;
import com.starrocks.sql.ast.ShowPartitionsStmt;
import com.starrocks.sql.ast.ShowProcedureStmt;
Expand Down Expand Up @@ -1173,6 +1174,14 @@ public Table getTable(String catalogName, String dbName, String tblName) {
resultSet.getResultRows().get(0).get(1));
}

@Test
public void testShowKeysFromTable() {
ShowIndexStmt stmt = new ShowIndexStmt("test_db",
new TableName(null, "test_db", "test_table"));
ShowResultSet resultSet = ShowExecutor.execute(stmt, ctx);
Assert.assertEquals(0, resultSet.getResultRows().size());
}

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

0 comments on commit c38a677

Please sign in to comment.