Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Improvement](profile) add catalog info in profile #38302

Merged
Merged
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 @@ -43,6 +43,7 @@ public class SummaryProfile {
public static final String TOTAL_TIME = "Total";
public static final String TASK_STATE = "Task State";
public static final String USER = "User";
public static final String DEFAULT_CATALOG = "Default Catalog";
public static final String DEFAULT_DB = "Default Db";
public static final String SQL_STATEMENT = "Sql Statement";
public static final String IS_CACHED = "Is Cached";
Expand Down Expand Up @@ -100,7 +101,7 @@ public class SummaryProfile {
// a column, so that should not
// add many columns here. Add to ExecutionSummary list.
public static final ImmutableList<String> SUMMARY_KEYS = ImmutableList.of(PROFILE_ID, TASK_TYPE,
START_TIME, END_TIME, TOTAL_TIME, TASK_STATE, USER, DEFAULT_DB, SQL_STATEMENT);
START_TIME, END_TIME, TOTAL_TIME, TASK_STATE, USER, DEFAULT_CATALOG, DEFAULT_DB, SQL_STATEMENT);

// The display order of execution summary items.
public static final ImmutableList<String> EXECUTION_SUMMARY_KEYS = ImmutableList.of(
Expand Down Expand Up @@ -536,6 +537,11 @@ public SummaryBuilder user(String val) {
return this;
}

public SummaryBuilder defaultCatalog(String val) {
map.put(DEFAULT_CATALOG, val);
return this;
}

public SummaryBuilder defaultDb(String val) {
map.put(DEFAULT_DB, val);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.apache.doris.common.util.MetaLockUtils;
import org.apache.doris.common.util.ProfileManager.ProfileType;
import org.apache.doris.common.util.TimeUtils;
import org.apache.doris.datasource.InternalCatalog;
import org.apache.doris.datasource.property.constants.S3Properties;
import org.apache.doris.load.BrokerFileGroup;
import org.apache.doris.load.BrokerFileGroupAggInfo.FileGroupAggKey;
Expand Down Expand Up @@ -352,6 +353,7 @@ private Map<String, String> getSummaryInfo(boolean isFinished) {
}
builder.taskState("FINISHED");
builder.user(getUserInfo() != null ? getUserInfo().getQualifiedUser() : "N/A");
builder.defaultCatalog(InternalCatalog.INTERNAL_CATALOG_NAME);
builder.defaultDb(getDefaultDb());
builder.sqlStatement(getOriginStmt().originStmt);
return builder.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ private Map<String, String> getSummaryInfo(boolean isFinished) {
builder.taskState(!isFinished && context.getState().getStateType().equals(MysqlStateType.OK) ? "RUNNING"
: context.getState().toString());
builder.user(context.getQualifiedUser());
builder.defaultCatalog(context.getCurrentCatalog().getName());
builder.defaultDb(context.getDatabase());
builder.workloadGroup(context.getWorkloadGroupName());
builder.sqlStatement(originStmt.originStmt);
Expand Down
20 changes: 1 addition & 19 deletions regression-test/suites/query_profile/test_profile.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -104,24 +104,6 @@ suite('test_profile') {
nums.add(getRandomNumber(len + 1))
sql """ SELECT * FROM ${table} WHERE cost ${ops[i]} ${nums[i]} """
}


/* test for `show query profile` stmt
query profile header
JobID|QueryId|User|DefaultDb|SQL|QueryType|StartTime|EndTime|TotalTime|QueryState */
//———————— test for select stmt (SQL) ———————————
log.info("test for show query profile stmt")
List<List<Object>> show_query_profile_obj = sql """ show query profile "/" """
log.info("found ${show_query_profile_obj.size} profile data".toString())
assertTrue(show_query_profile_obj.size >= QUERY_NUM)

for(int i = 0 ; i < QUERY_NUM ; i++){
def insert_order = QUERY_NUM - i - 1
def current_obj = show_query_profile_obj[i]
def stmt_query_info = current_obj[9]
assertNotEquals(current_obj[1].toString(), "N/A".toString())
assertEquals(stmt_query_info.toString(), """ SELECT * FROM ${table} WHERE cost ${ops[insert_order]} ${nums[insert_order]} """.toString())
}

//———————— test for select stmt (HTTP)————————
log.info("test HTTP API interface for query profile")
Expand All @@ -138,7 +120,7 @@ suite('test_profile') {

assertNotNull(stmt_query_info["Profile ID"])
assertNotEquals(stmt_query_info["Profile ID"].toString(), "N/A".toString())

assertNotNull(stmt_query_info["Default Catalog"])
assertEquals(stmt_query_info['Sql Statement'].toString(),
""" SELECT * FROM ${table} WHERE cost ${ops[insert_order]} ${nums[insert_order]} """.toString())
}
Expand Down
Loading