[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() {

View File

@ -1,150 +1,101 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !1 --
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[INNER_JOIN] hashCondition=((partsupp.ps_suppkey = supplier.s_suppkey))otherCondition=()
--------hashJoin[INNER_JOIN] hashCondition=((nation.n_nationkey = supplier.s_suppkey))otherCondition=()
----------hashJoin[INNER_JOIN] hashCondition=((region.r_regionkey = nation.n_regionkey))otherCondition=()
------------PhysicalOlapScan[region]
------------PhysicalDistribute
--------------filter(( not n_nationkey IS NULL) and (nation.n_nationkey > 1))
----------------PhysicalOlapScan[nation]
----------PhysicalDistribute
------------filter(( not s_suppkey IS NULL) and (supplier.s_suppkey > 1))
--------------PhysicalOlapScan[supplier]
--------PhysicalDistribute
----------filter(( not ps_suppkey IS NULL) and (partsupp.ps_suppkey > 1))
------------PhysicalOlapScan[partsupp]
--hashJoin[INNER_JOIN] hashCondition=((partsupp.ps_suppkey = supplier.s_suppkey))otherCondition=()
----hashJoin[INNER_JOIN] hashCondition=((nation.n_nationkey = supplier.s_suppkey))otherCondition=()
------hashJoin[INNER_JOIN] hashCondition=((region.r_regionkey = nation.n_regionkey))otherCondition=()
--------PhysicalOlapScan[region]
--------filter(( not n_nationkey IS NULL) and (nation.n_nationkey > 1))
----------PhysicalOlapScan[nation]
------filter(( not s_suppkey IS NULL) and (supplier.s_suppkey > 1))
--------PhysicalOlapScan[supplier]
----filter(( not ps_suppkey IS NULL) and (partsupp.ps_suppkey > 1))
------PhysicalOlapScan[partsupp]
-- !2 --
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[RIGHT_OUTER_JOIN] hashCondition=((partsupp.ps_suppkey = supplier.s_suppkey))otherCondition=()
--------PhysicalDistribute
----------filter((supplier.s_suppkey > 1))
------------hashJoin[FULL_OUTER_JOIN] hashCondition=((nation.n_nationkey = supplier.s_suppkey))otherCondition=()
--------------PhysicalDistribute
----------------hashJoin[FULL_OUTER_JOIN] hashCondition=((region.r_regionkey = nation.n_regionkey))otherCondition=()
------------------PhysicalDistribute
--------------------PhysicalOlapScan[region]
------------------PhysicalDistribute
--------------------PhysicalOlapScan[nation]
--------------PhysicalDistribute
----------------PhysicalOlapScan[supplier]
--------PhysicalDistribute
----------filter(( not ps_suppkey IS NULL) and (partsupp.ps_suppkey > 1))
------------PhysicalOlapScan[partsupp]
--hashJoin[RIGHT_OUTER_JOIN] hashCondition=((partsupp.ps_suppkey = supplier.s_suppkey))otherCondition=()
----filter((supplier.s_suppkey > 1))
------hashJoin[FULL_OUTER_JOIN] hashCondition=((nation.n_nationkey = supplier.s_suppkey))otherCondition=()
--------hashJoin[FULL_OUTER_JOIN] hashCondition=((region.r_regionkey = nation.n_regionkey))otherCondition=()
----------PhysicalOlapScan[region]
----------PhysicalOlapScan[nation]
--------PhysicalOlapScan[supplier]
----filter(( not ps_suppkey IS NULL) and (partsupp.ps_suppkey > 1))
------PhysicalOlapScan[partsupp]
-- !3 --
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[RIGHT_OUTER_JOIN] hashCondition=((partsupp.ps_suppkey = supplier.s_suppkey))otherCondition=()
--------PhysicalDistribute
----------filter((supplier.s_suppkey > 1))
------------hashJoin[LEFT_OUTER_JOIN] hashCondition=((nation.n_nationkey = supplier.s_suppkey))otherCondition=()
--------------hashJoin[FULL_OUTER_JOIN] hashCondition=((region.r_regionkey = nation.n_regionkey))otherCondition=()
----------------PhysicalDistribute
------------------PhysicalOlapScan[region]
----------------PhysicalDistribute
------------------PhysicalOlapScan[nation]
--------------PhysicalDistribute
----------------PhysicalOlapScan[supplier]
--------PhysicalDistribute
----------filter(( not ps_suppkey IS NULL) and (partsupp.ps_suppkey > 1))
------------PhysicalOlapScan[partsupp]
--hashJoin[RIGHT_OUTER_JOIN] hashCondition=((partsupp.ps_suppkey = supplier.s_suppkey))otherCondition=()
----filter((supplier.s_suppkey > 1))
------hashJoin[LEFT_OUTER_JOIN] hashCondition=((nation.n_nationkey = supplier.s_suppkey))otherCondition=()
--------hashJoin[FULL_OUTER_JOIN] hashCondition=((region.r_regionkey = nation.n_regionkey))otherCondition=()
----------PhysicalOlapScan[region]
----------PhysicalOlapScan[nation]
--------PhysicalOlapScan[supplier]
----filter(( not ps_suppkey IS NULL) and (partsupp.ps_suppkey > 1))
------PhysicalOlapScan[partsupp]
-- !4 --
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[LEFT_OUTER_JOIN] hashCondition=((region.r_regionkey = nation.n_regionkey))otherCondition=()
--------filter(( not r_name IS NULL) and (region.r_name = ''))
----------PhysicalOlapScan[region]
--------PhysicalDistribute
----------PhysicalOlapScan[nation]
--hashJoin[LEFT_OUTER_JOIN] hashCondition=((region.r_regionkey = nation.n_regionkey))otherCondition=()
----filter(( not r_name IS NULL) and (region.r_name = ''))
------PhysicalOlapScan[region]
----PhysicalOlapScan[nation]
-- !5 --
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[LEFT_OUTER_JOIN] hashCondition=((nation.n_nationkey = supplier.s_suppkey))otherCondition=()
--------hashJoin[LEFT_OUTER_JOIN] hashCondition=((region.r_regionkey = nation.n_regionkey))otherCondition=()
----------filter(( not r_name IS NULL) and (region.r_name = ''))
------------PhysicalOlapScan[region]
----------PhysicalDistribute
------------PhysicalOlapScan[nation]
--------PhysicalDistribute
----------PhysicalOlapScan[supplier]
--hashJoin[LEFT_OUTER_JOIN] hashCondition=((nation.n_nationkey = supplier.s_suppkey))otherCondition=()
----hashJoin[LEFT_OUTER_JOIN] hashCondition=((region.r_regionkey = nation.n_regionkey))otherCondition=()
------filter(( not r_name IS NULL) and (region.r_name = ''))
--------PhysicalOlapScan[region]
------PhysicalOlapScan[nation]
----PhysicalOlapScan[supplier]
-- !6 --
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[LEFT_OUTER_JOIN] hashCondition=((partsupp.ps_suppkey = supplier.s_suppkey))otherCondition=()
--------hashJoin[LEFT_OUTER_JOIN] hashCondition=((nation.n_nationkey = supplier.s_suppkey))otherCondition=()
----------hashJoin[LEFT_OUTER_JOIN] hashCondition=((region.r_regionkey = nation.n_regionkey))otherCondition=()
------------filter(( not r_name IS NULL) and (region.r_name = ''))
--------------PhysicalOlapScan[region]
------------PhysicalDistribute
--------------PhysicalOlapScan[nation]
----------PhysicalDistribute
------------PhysicalOlapScan[supplier]
--------PhysicalDistribute
----------PhysicalOlapScan[partsupp]
--hashJoin[LEFT_OUTER_JOIN] hashCondition=((partsupp.ps_suppkey = supplier.s_suppkey))otherCondition=()
----hashJoin[LEFT_OUTER_JOIN] hashCondition=((nation.n_nationkey = supplier.s_suppkey))otherCondition=()
------hashJoin[LEFT_OUTER_JOIN] hashCondition=((region.r_regionkey = nation.n_regionkey))otherCondition=()
--------filter(( not r_name IS NULL) and (region.r_name = ''))
----------PhysicalOlapScan[region]
--------PhysicalOlapScan[nation]
------PhysicalOlapScan[supplier]
----PhysicalOlapScan[partsupp]
-- !7 --
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[FULL_OUTER_JOIN] hashCondition=((partsupp.ps_suppkey = supplier.s_suppkey))otherCondition=()
--------PhysicalDistribute
----------hashJoin[LEFT_OUTER_JOIN] hashCondition=((nation.n_nationkey = supplier.s_suppkey))otherCondition=()
------------hashJoin[INNER_JOIN] hashCondition=((region.r_regionkey = nation.n_regionkey))otherCondition=()
--------------filter(( not r_regionkey IS NULL))
----------------PhysicalOlapScan[region]
--------------PhysicalDistribute
----------------filter(( not n_regionkey IS NULL))
------------------PhysicalOlapScan[nation]
------------PhysicalDistribute
--------------PhysicalOlapScan[supplier]
--------PhysicalDistribute
----------PhysicalOlapScan[partsupp]
--hashJoin[FULL_OUTER_JOIN] hashCondition=((partsupp.ps_suppkey = supplier.s_suppkey))otherCondition=()
----hashJoin[LEFT_OUTER_JOIN] hashCondition=((nation.n_nationkey = supplier.s_suppkey))otherCondition=()
------hashJoin[INNER_JOIN] hashCondition=((region.r_regionkey = nation.n_regionkey))otherCondition=()
--------filter(( not r_regionkey IS NULL))
----------PhysicalOlapScan[region]
--------filter(( not n_regionkey IS NULL))
----------PhysicalOlapScan[nation]
------PhysicalOlapScan[supplier]
----PhysicalOlapScan[partsupp]
-- !8 --
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[LEFT_OUTER_JOIN] hashCondition=((partsupp.ps_suppkey = supplier.s_suppkey))otherCondition=()
--------hashJoin[LEFT_OUTER_JOIN] hashCondition=((nation.n_nationkey = supplier.s_suppkey))otherCondition=()
----------hashJoin[INNER_JOIN] hashCondition=((region.r_regionkey = nation.n_regionkey))otherCondition=()
------------PhysicalDistribute
--------------filter(( not r_name IS NULL) and ( not r_regionkey IS NULL) and (region.r_name = ''))
----------------PhysicalOlapScan[region]
------------PhysicalDistribute
--------------filter(( not n_regionkey IS NULL))
----------------PhysicalOlapScan[nation]
----------PhysicalDistribute
------------PhysicalOlapScan[supplier]
--------PhysicalDistribute
----------PhysicalOlapScan[partsupp]
--hashJoin[LEFT_OUTER_JOIN] hashCondition=((partsupp.ps_suppkey = supplier.s_suppkey))otherCondition=()
----hashJoin[LEFT_OUTER_JOIN] hashCondition=((nation.n_nationkey = supplier.s_suppkey))otherCondition=()
------hashJoin[INNER_JOIN] hashCondition=((region.r_regionkey = nation.n_regionkey))otherCondition=()
--------filter(( not r_name IS NULL) and ( not r_regionkey IS NULL) and (region.r_name = ''))
----------PhysicalOlapScan[region]
--------filter(( not n_regionkey IS NULL))
----------PhysicalOlapScan[nation]
------PhysicalOlapScan[supplier]
----PhysicalOlapScan[partsupp]
-- !9 --
PhysicalResultSink
--PhysicalDistribute
----PhysicalProject
------hashJoin[LEFT_OUTER_JOIN] hashCondition=((partsupp.ps_suppkey = supplier.s_suppkey))otherCondition=()
--------hashJoin[INNER_JOIN] hashCondition=((nation.n_nationkey = supplier.s_suppkey))otherCondition=()
----------hashJoin[INNER_JOIN] hashCondition=((region.r_regionkey = nation.n_regionkey))otherCondition=()
------------filter(( not r_name IS NULL) and ( not r_regionkey IS NULL) and (region.r_name = ''))
--------------PhysicalOlapScan[region]
------------PhysicalDistribute
--------------filter(( not n_regionkey IS NULL))
----------------PhysicalOlapScan[nation]
----------PhysicalDistribute
------------PhysicalOlapScan[supplier]
--------PhysicalDistribute
----------PhysicalOlapScan[partsupp]
--hashJoin[LEFT_OUTER_JOIN] hashCondition=((partsupp.ps_suppkey = supplier.s_suppkey))otherCondition=()
----hashJoin[INNER_JOIN] hashCondition=((nation.n_nationkey = supplier.s_suppkey))otherCondition=()
------hashJoin[INNER_JOIN] hashCondition=((region.r_regionkey = nation.n_regionkey))otherCondition=()
--------filter(( not r_name IS NULL) and ( not r_regionkey IS NULL) and (region.r_name = ''))
----------PhysicalOlapScan[region]
--------filter(( not n_regionkey IS NULL))
----------PhysicalOlapScan[nation]
------PhysicalOlapScan[supplier]
----PhysicalOlapScan[partsupp]

View File

@ -22,7 +22,9 @@ suite("eliminate_outer_join") {
sql "set disable_join_reorder=true"
sql "set forbid_unknown_col_stats=false"
sql "set enable_bucket_shuffle_join=false"
sql """
set ignore_shape_nodes='PhysicalDistribute, PhysicalProject'
"""
String database = context.config.getDbNameByFile(context.file)
sql "drop database if exists ${database}"
sql "create database ${database}"