[feature](nereids)Ignore some node in 'explain shape plan' command (#25485)

if set ignore_shape_nodes='PhysicalDistribute, PhysicalProject'
then
explain shape plan will not print project and distribute node
This commit is contained in:
minghong
2023-10-17 11:57:36 +08:00
committed by GitHub
parent c2fe34dec7
commit 0ee06f30b0
4 changed files with 99 additions and 125 deletions

View File

@ -27,6 +27,7 @@ import org.apache.doris.nereids.trees.expressions.NamedExpression;
import org.apache.doris.nereids.trees.expressions.Slot;
import org.apache.doris.nereids.trees.plans.visitor.PlanVisitor;
import org.apache.doris.nereids.util.MutableState;
import org.apache.doris.qe.ConnectContext;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
@ -156,8 +157,13 @@ public interface Plan extends TreeNode<Plan> {
*/
default String shape(String prefix) {
StringBuilder builder = new StringBuilder();
builder.append(prefix).append(shapeInfo()).append("\n");
String childPrefix = prefix + "--";
String me = shapeInfo();
String prefixTail = "";
if (! ConnectContext.get().getSessionVariable().getIgnoreShapePlanNodes().contains(me)) {
builder.append(prefix).append(shapeInfo()).append("\n");
prefixTail += "--";
}
String childPrefix = prefix + prefixTail;
children().forEach(
child -> {
builder.append(child.shape(childPrefix));

View File

@ -1239,6 +1239,21 @@ public class SessionVariable implements Serializable, Writable {
description = {"是否启用更快的浮点数转换算法,注意会影响输出格式", "Set true to enable faster float pointer number convert"})
public boolean fasterFloatConvert = false;
public static final String IGNORE_SHAPE_NODE = "ignore_shape_nodes";
public Set<String> getIgnoreShapePlanNodes() {
return Arrays.stream(ignoreShapePlanNodes.split(",[\\s]*")).collect(ImmutableSet.toImmutableSet());
}
public void setIgnoreShapePlanNodes(String ignoreShapePlanNodes) {
this.ignoreShapePlanNodes = ignoreShapePlanNodes;
}
@VariableMgr.VarAttr(name = IGNORE_SHAPE_NODE,
description = {"'explain shape plan' 命令中忽略的PlanNode 类型",
"the plan node type which is ignored in 'explain shape plan' command"})
public String ignoreShapePlanNodes = "";
// If this fe is in fuzzy mode, then will use initFuzzyModeVariables to generate some variables,
// not the default value set in the code.
public void initFuzzyModeVariables() {