Skip to content

Commit

Permalink
[Improvement](profile) add catalog info in profile (apache#38298)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yulei-Yang authored and weixingyu12 committed Jul 28, 2024
1 parent 7b31e87 commit 63dfe3a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,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 @@ -78,7 +79,7 @@ public class SummaryProfile {
// a column, so that should not
// add many columns here. Add to ExcecutionSummary 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);

public static final ImmutableList<String> EXECUTION_SUMMARY_KEYS = ImmutableList.of(
WORKLOAD_GROUP,
Expand Down Expand Up @@ -345,6 +346,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 @@ -42,6 +42,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 @@ -357,6 +358,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 @@ -332,6 +332,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
2 changes: 1 addition & 1 deletion regression-test/suites/query_profile/test_profile.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,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

0 comments on commit 63dfe3a

Please sign in to comment.