Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ supportedShowStatement
| SHOW (WARNINGS | ERRORS) limitClause? #showWarningErrors
| SHOW COUNT LEFT_PAREN ASTERISK RIGHT_PAREN (WARNINGS | ERRORS) #showWarningErrorCount
| SHOW BACKENDS #showBackends
| SHOW BACKENDS backendIds+=INTEGER_VALUE (COMMA backendIds+=INTEGER_VALUE)* #showBackendsWithIds
| SHOW STAGES #showStages
| SHOW REPLICA DISTRIBUTION FROM baseTableRef #showReplicaDistribution
| SHOW RESOURCES wildWhere? sortClause? limitClause? #showResources
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@
import org.apache.doris.nereids.DorisParser.ShowAnalyzeTaskContext;
import org.apache.doris.nereids.DorisParser.ShowAuthorsContext;
import org.apache.doris.nereids.DorisParser.ShowBackendsContext;
import org.apache.doris.nereids.DorisParser.ShowBackendsWithIdsContext;
import org.apache.doris.nereids.DorisParser.ShowBackupContext;
import org.apache.doris.nereids.DorisParser.ShowBrokerContext;
import org.apache.doris.nereids.DorisParser.ShowBuildIndexContext;
Expand Down Expand Up @@ -6180,6 +6181,14 @@ public LogicalPlan visitShowBackends(ShowBackendsContext ctx) {
return new ShowBackendsCommand();
}

@Override
public LogicalPlan visitShowBackendsWithIds(ShowBackendsWithIdsContext ctx) {
List<Long> backendIds = ctx.backendIds.stream()
.map(token -> Long.parseLong(token.getText()))
.collect(Collectors.toList());
return new ShowBackendsCommand(backendIds);
}

@Override
public LogicalPlan visitShowBackup(ShowBackupContext ctx) {
String dbName = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,28 @@
import org.apache.doris.qe.StmtExecutor;

import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

/**
* show backends command
*/
public class ShowBackendsCommand extends ShowCommand {

private final List<Long> backendIds;

/**
* constructor
*/
public ShowBackendsCommand() {
this(null);
}

public ShowBackendsCommand(List<Long> backendIds) {
super(PlanType.SHOW_BACKENDS_COMMAND);
this.backendIds = backendIds;
}

public ShowResultSetMetaData getMetaData() {
Expand All @@ -66,6 +76,12 @@ public ShowResultSet doRun(ConnectContext ctx, StmtExecutor executor) throws Exc
}

List<List<String>> backendInfos = BackendsProcDir.getBackendInfos();
if (backendIds != null && !backendIds.isEmpty()) {
Set<Long> idSet = new HashSet<>(backendIds);
backendInfos = backendInfos.stream()
.filter(info -> idSet.contains(Long.parseLong(info.get(0))))
.collect(Collectors.toList());
}
backendInfos.sort(new Comparator<List<String>>() {
@Override
public int compare(List<String> o1, List<String> o2) {
Expand Down