[fix](profile) fix show load query profile (#18487)
Sometimes, `show load profile` will only show part of the insert opertion's profile.
This is because we assume that for all load operation(including insert), there is only one fragment in the plan.
But actually, there will be more than 1 fragment in plan. eg:
`insert into tbl1 select * from tbl1 limit 1` will have 2 fragments.
This PR mainly changes:
1. modify the `show load profile`
Before: `show load profile "/queryid/taskid/instanceid";`
After: `show load profile "/queryid/taskid/fragmentid/instanceid";`
2. Modify the display of `ReadColumns` in OlapScanNode
Because for wide table, the line of `ReadColumns` may be too long for show in profile.
So I wrap it and each line contains at most 10 columns names.
3. Fix tvf not working with pipeline engine, follow up #18376
This commit is contained in:
@ -40,6 +40,7 @@ public class ShowLoadProfileStmt extends ShowStmt {
|
||||
public enum PathType {
|
||||
QUERY_IDS,
|
||||
TASK_IDS,
|
||||
FRAGMENTS,
|
||||
INSTANCES,
|
||||
SINGLE_INSTANCE
|
||||
}
|
||||
@ -49,6 +50,7 @@ public class ShowLoadProfileStmt extends ShowStmt {
|
||||
|
||||
private String jobId = "";
|
||||
private String taskId = "";
|
||||
private String fragmentId = "";
|
||||
private String instanceId = "";
|
||||
|
||||
public ShowLoadProfileStmt(String idPath) {
|
||||
@ -67,6 +69,10 @@ public class ShowLoadProfileStmt extends ShowStmt {
|
||||
return taskId;
|
||||
}
|
||||
|
||||
public String getFragmentId() {
|
||||
return fragmentId;
|
||||
}
|
||||
|
||||
public String getInstanceId() {
|
||||
return instanceId;
|
||||
}
|
||||
@ -85,8 +91,8 @@ public class ShowLoadProfileStmt extends ShowStmt {
|
||||
}
|
||||
pathType = PathType.QUERY_IDS;
|
||||
String[] parts = idPath.split("/");
|
||||
if (parts.length > 4) {
|
||||
throw new AnalysisException("Path must in format '/jobId/taskId/instanceId'");
|
||||
if (parts.length > 5) {
|
||||
throw new AnalysisException("Path must in format '/jobId/taskId/fragmentId/instanceId'");
|
||||
}
|
||||
|
||||
for (int i = 0; i < parts.length; i++) {
|
||||
@ -100,9 +106,13 @@ public class ShowLoadProfileStmt extends ShowStmt {
|
||||
break;
|
||||
case 2:
|
||||
taskId = parts[i];
|
||||
pathType = PathType.INSTANCES;
|
||||
pathType = PathType.FRAGMENTS;
|
||||
break;
|
||||
case 3:
|
||||
fragmentId = parts[i];
|
||||
pathType = PathType.INSTANCES;
|
||||
break;
|
||||
case 4:
|
||||
instanceId = parts[i];
|
||||
pathType = PathType.SINGLE_INSTANCE;
|
||||
break;
|
||||
@ -130,6 +140,8 @@ public class ShowLoadProfileStmt extends ShowStmt {
|
||||
return ShowQueryProfileStmt.META_DATA_QUERY_IDS;
|
||||
case TASK_IDS:
|
||||
return META_DATA_TASK_IDS;
|
||||
case FRAGMENTS:
|
||||
return ShowQueryProfileStmt.META_DATA_FRAGMENTS;
|
||||
case INSTANCES:
|
||||
return ShowQueryProfileStmt.META_DATA_INSTANCES;
|
||||
case SINGLE_INSTANCE:
|
||||
@ -139,3 +151,4 @@ public class ShowLoadProfileStmt extends ShowStmt {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -70,7 +70,7 @@ public class ShowQueryProfileStmt extends ShowStmt {
|
||||
|
||||
public enum PathType {
|
||||
QUERY_IDS,
|
||||
FRAGMETNS,
|
||||
FRAGMENTS,
|
||||
INSTANCES,
|
||||
SINGLE_INSTANCE
|
||||
}
|
||||
@ -127,7 +127,7 @@ public class ShowQueryProfileStmt extends ShowStmt {
|
||||
continue;
|
||||
case 1:
|
||||
queryId = parts[i];
|
||||
pathType = PathType.FRAGMETNS;
|
||||
pathType = PathType.FRAGMENTS;
|
||||
break;
|
||||
case 2:
|
||||
fragmentId = parts[i];
|
||||
@ -159,7 +159,7 @@ public class ShowQueryProfileStmt extends ShowStmt {
|
||||
switch (pathType) {
|
||||
case QUERY_IDS:
|
||||
return META_DATA_QUERY_IDS;
|
||||
case FRAGMETNS:
|
||||
case FRAGMENTS:
|
||||
return META_DATA_FRAGMENTS;
|
||||
case INSTANCES:
|
||||
return META_DATA_INSTANCES;
|
||||
@ -170,3 +170,4 @@ public class ShowQueryProfileStmt extends ShowStmt {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2084,7 +2084,7 @@ public class ShowExecutor {
|
||||
case QUERY_IDS:
|
||||
rows = ProfileManager.getInstance().getQueryWithType(ProfileManager.ProfileType.QUERY);
|
||||
break;
|
||||
case FRAGMETNS: {
|
||||
case FRAGMENTS: {
|
||||
ProfileTreeNode treeRoot = ProfileManager.getInstance().getFragmentProfileTree(showStmt.getQueryId(),
|
||||
showStmt.getQueryId());
|
||||
if (treeRoot == null) {
|
||||
@ -2143,12 +2143,22 @@ public class ShowExecutor {
|
||||
rows = ProfileManager.getInstance().getLoadJobTaskList(showStmt.getJobId());
|
||||
break;
|
||||
}
|
||||
case FRAGMENTS: {
|
||||
ProfileTreeNode treeRoot = ProfileManager.getInstance().getFragmentProfileTree(showStmt.getJobId(),
|
||||
showStmt.getJobId());
|
||||
if (treeRoot == null) {
|
||||
throw new AnalysisException("Failed to get fragment tree for load: " + showStmt.getJobId());
|
||||
}
|
||||
List<String> row = Lists.newArrayList(ProfileTreePrinter.printFragmentTree(treeRoot));
|
||||
rows.add(row);
|
||||
break;
|
||||
}
|
||||
case INSTANCES: {
|
||||
// For load profile, there should be only one fragment in each execution profile
|
||||
// And the fragment id is 0.
|
||||
List<Triple<String, String, Long>> instanceList
|
||||
= ProfileManager.getInstance().getFragmentInstanceList(showStmt.getJobId(),
|
||||
showStmt.getTaskId(), "0");
|
||||
showStmt.getTaskId(), ((ShowLoadProfileStmt) stmt).getFragmentId());
|
||||
if (instanceList == null) {
|
||||
throw new AnalysisException("Failed to get instance list for task: " + showStmt.getTaskId());
|
||||
}
|
||||
@ -2163,7 +2173,7 @@ public class ShowExecutor {
|
||||
// For load profile, there should be only one fragment in each execution profile.
|
||||
// And the fragment id is 0.
|
||||
ProfileTreeNode treeRoot = ProfileManager.getInstance().getInstanceProfileTree(showStmt.getJobId(),
|
||||
showStmt.getTaskId(), "0", showStmt.getInstanceId());
|
||||
showStmt.getTaskId(), showStmt.getFragmentId(), showStmt.getInstanceId());
|
||||
if (treeRoot == null) {
|
||||
throw new AnalysisException("Failed to get instance tree for instance: "
|
||||
+ showStmt.getInstanceId());
|
||||
@ -2644,3 +2654,4 @@ public class ShowExecutor {
|
||||
resultSet = new ShowResultSet(showMetaData, resultRowSet);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user