This is an automated email from the ASF dual-hosted git repository. dataroaring pushed a commit to branch branch-3.0 in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.0 by this push: new 9e305608455 branch-3.0: [Fix]fix http query_info api return wrong column (#43839) 9e305608455 is described below commit 9e305608455fb5c41e366d5cf1971bf727f8b211 Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> AuthorDate: Thu Nov 14 14:38:11 2024 +0800 branch-3.0: [Fix]fix http query_info api return wrong column (#43839) Cherry-picked from #43724 Co-authored-by: wangbo <wan...@selectdb.com> --- .../apache/doris/common/profile/ProfileManager.java | 6 +++++- .../httpv2/rest/manager/QueryProfileAction.java | 20 +++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/common/profile/ProfileManager.java b/fe/fe-core/src/main/java/org/apache/doris/common/profile/ProfileManager.java index 3177b5738ed..981d025792c 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/common/profile/ProfileManager.java +++ b/fe/fe-core/src/main/java/org/apache/doris/common/profile/ProfileManager.java @@ -223,6 +223,10 @@ public class ProfileManager extends MasterDaemon { } public List<List<String>> getAllQueries() { + return getQueryInfoByColumnNameList(SummaryProfile.SUMMARY_KEYS); + } + + public List<List<String>> getQueryInfoByColumnNameList(List<String> columnNameList) { List<List<String>> result = Lists.newArrayList(); readLock.lock(); try { @@ -231,7 +235,7 @@ public class ProfileManager extends MasterDaemon { ProfileElement profileElement = queueIdDeque.poll(); Map<String, String> infoStrings = profileElement.infoStrings; List<String> row = Lists.newArrayList(); - for (String str : SummaryProfile.SUMMARY_KEYS) { + for (String str : columnNameList) { row.add(infoStrings.get(str)); } result.add(row); diff --git a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/manager/QueryProfileAction.java b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/manager/QueryProfileAction.java index 625b307c43e..8c3dfa73aea 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/manager/QueryProfileAction.java +++ b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/manager/QueryProfileAction.java @@ -27,6 +27,7 @@ import org.apache.doris.common.proc.CurrentQueryStatementsProcNode; import org.apache.doris.common.proc.ProcResult; import org.apache.doris.common.profile.ProfileManager; import org.apache.doris.common.profile.ProfileManager.ProfileElement; +import org.apache.doris.common.profile.SummaryProfile; import org.apache.doris.common.util.NetUtils; import org.apache.doris.httpv2.entity.ResponseEntityBuilder; import org.apache.doris.httpv2.rest.RestBaseController; @@ -105,6 +106,18 @@ public class QueryProfileAction extends RestBaseController { .add(NODE).add(USER).add(DEFAULT_DB).add(SQL_STATEMENT).add(QUERY_TYPE).add(START_TIME).add(END_TIME) .add(TOTAL).add(QUERY_STATE).build(); + // As an old http api, query_info's output schema column is established since 1.2, + // so it can not be changed for compatibility. + // Now query_info api get data from ProfileManager, its column name is different but has the same meaning with + // QUERY_TITLE_NAMES. + // We should keep PROFILE_TITLE_NAMES and QUERY_TITLE_NAMES has the same meaning, and use PROFILE_TITLE_NAMES + // to get data from profile manager. + public static final ImmutableList<String> PROFILE_TITLE_NAMES = new ImmutableList.Builder<String>() + .add(SummaryProfile.PROFILE_ID).add(NODE) + .add(SummaryProfile.USER).add(SummaryProfile.DEFAULT_DB).add(SummaryProfile.SQL_STATEMENT) + .add(SummaryProfile.TASK_TYPE).add(SummaryProfile.START_TIME).add(SummaryProfile.END_TIME) + .add(SummaryProfile.TOTAL_TIME).add(SummaryProfile.TASK_STATE).build(); + private List<String> requestAllFe(String httpPath, Map<String, String> arguments, String authorization, HttpMethod method) { List<Pair<String, Integer>> frontends = HttpUtils.getFeList(); @@ -169,14 +182,15 @@ public class QueryProfileAction extends RestBaseController { return ResponseEntityBuilder.ok(new NodeAction.NodeInfo(QUERY_TITLE_NAMES, queries)); } - Stream<List<String>> queryStream = ProfileManager.getInstance().getAllQueries().stream() - .filter(profile -> profile.get(1).equalsIgnoreCase("Query")); + Stream<List<String>> queryStream = ProfileManager.getInstance() + .getQueryInfoByColumnNameList(PROFILE_TITLE_NAMES).stream() + .filter(profile -> profile.get(5).equalsIgnoreCase("Query")); queryStream = filterQueriesByUserAndQueryId(queryStream, queryId); queries = queryStream.collect(Collectors.toList()); // add node information for (List<String> query : queries) { - query.add(1, NetUtils.getHostPortInAccessibleFormat(Env.getCurrentEnv().getSelfNode().getHost(), + query.set(1, NetUtils.getHostPortInAccessibleFormat(Env.getCurrentEnv().getSelfNode().getHost(), Config.http_port)); } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org