924060929 opened a new issue, #14554: URL: https://github.com/apache/doris/issues/14554
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/doris/issues?q=is%3Aissue) and found no similar issues. ### Description In the past, nereids only explain the plan through TreeNode tree, this only display the partial information of current node and the children node. For example: The parsed plan hide the child plan of LogicalSubQueryAlias ( alias=s ) in the LogicalCTE. ``` MySQL [regression_test_nereids_syntax_p0]> explain plan with s as (select * from supplier) select * from s as s1, s as s2; +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Explain String | +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | ========== PARSED PLAN ========== | | LogicalCTE ( aliasQueries=[LogicalSubQueryAlias ( alias=s )] ) | | +--LogicalProject ( projects=[*] ) | | +--LogicalJoin ( type=CROSS_JOIN, hashJoinConjuncts=[], otherJoinConjuncts=[] ) | | |--LogicalSubQueryAlias ( alias=s1 ) | | | +--UnboundRelation ( nameParts=s ) | | +--LogicalSubQueryAlias ( alias=s2 ) | | +--UnboundRelation ( nameParts=s ) | | | | ========== ANALYZED PLAN ========== | | LogicalProject ( projects=[s_suppkey#0, s_name#1, s_address#2, s_city#3, s_nation#4, s_region#5, s_phone#6, s_suppkey#7, s_name#8, s_address#9, s_city#10, s_nation#11, s_region#12, s_phone#13] ) | | +--LogicalJoin ( type=CROSS_JOIN, hashJoinConjuncts=[], otherJoinConjuncts=[] ) | | |--LogicalProject ( projects=[s_suppkey#0, s_name#1, s_address#2, s_city#3, s_nation#4, s_region#5, s_phone#6] ) | | | +--LogicalProject ( projects=[s_suppkey#0, s_name#1, s_address#2, s_city#3, s_nation#4, s_region#5, s_phone#6] ) | | | +--LogicalProject ( projects=[s_suppkey#0, s_name#1, s_address#2, s_city#3, s_nation#4, s_region#5, s_phone#6] ) | | | +--LogicalOlapScan ( qualified=default_cluster:regression_test_nereids_syntax_p0.supplier, output=[s_suppkey#0, s_name#1, s_address#2, s_city#3, s_nation#4, s_region#5, s_phone#6], candidateIndexIds=[], selectedIndexId=17744, preAgg=ON ) | | +--LogicalProject ( projects=[s_suppkey#7, s_name#8, s_address#9, s_city#10, s_nation#11, s_region#12, s_phone#13] ) | | +--LogicalProject ( projects=[s_suppkey#7, s_name#8, s_address#9, s_city#10, s_nation#11, s_region#12, s_phone#13] ) | | +--LogicalProject ( projects=[s_suppkey#7, s_name#8, s_address#9, s_city#10, s_nation#11, s_region#12, s_phone#13] ) | | +--LogicalProject ( projects=[s_suppkey#7, s_name#8, s_address#9, s_city#10, s_nation#11, s_region#12, s_phone#13] ) | | +--LogicalOlapScan ( qualified=default_cluster:regression_test_nereids_syntax_p0.supplier, output=[s_suppkey#7, s_name#8, s_address#9, s_city#10, s_nation#11, s_region#12, s_phone#13], candidateIndexIds=[], selectedIndexId=17744, preAgg=ON ) | | | | ========== REWRITTEN PLAN ========== | | LogicalJoin ( type=CROSS_JOIN, hashJoinConjuncts=[], otherJoinConjuncts=[] ) | | |--LogicalOlapScan ( qualified=default_cluster:regression_test_nereids_syntax_p0.supplier, output=[s_suppkey#0, s_name#1, s_address#2, s_city#3, s_nation#4, s_region#5, s_phone#6], candidateIndexIds=[17744], selectedIndexId=17744, preAgg=ON ) | | +--LogicalOlapScan ( qualified=default_cluster:regression_test_nereids_syntax_p0.supplier, output=[s_suppkey#7, s_name#8, s_address#9, s_city#10, s_nation#11, s_region#12, s_phone#13], candidateIndexIds=[17744], selectedIndexId=17744, preAgg=ON ) | | | | ========== OPTIMIZED PLAN ========== | | PhysicalNestedLoopJoin ( type=CROSS_JOIN, otherJoinCondition=[] ) | | |--PhysicalOlapScan ( qualified=default_cluster:regression_test_nereids_syntax_p0.supplier, output=[s_suppkey#7, s_name#8, s_address#9, s_city#10, s_nation#11, s_region#12, s_phone#13], stats=(rows=3, isReduced=false, width=1, penalty=0.0) ) | | +--PhysicalDistribute ( distributionSpec=DistributionSpecReplicated, stats=(rows=3, isReduced=false, width=1, penalty=0.0) ) | | +--PhysicalOlapScan ( qualified=default_cluster:regression_test_nereids_syntax_p0.supplier, output=[s_suppkey#0, s_name#1, s_address#2, s_city#3, s_nation#4, s_region#5, s_phone#6], stats=(rows=3, isReduced=false, width=1, penalty=0.0) ) | +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 32 rows in set (0.007 sec) ``` ### Solution A solution is that we can provide an `Plan.extraPlans` like this: ```java class Plan { List<Plan> extraPlans(); } ``` And then combine the extra plans and the children in the `AbstractPlan.treeString()` ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org