From 7a82825a220bccab8aab3f14e71f61ecddec3a64 Mon Sep 17 00:00:00 2001 From: minghong Date: Thu, 19 Dec 2024 14:12:06 +0800 Subject: [PATCH] when check shape failed, print all plan with memo --- .../org/apache/doris/nereids/NereidsPlanner.java | 4 +++- .../apache/doris/regression/suite/Suite.groovy | 15 ++++++++++++--- .../shape/query35.groovy | 2 +- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/NereidsPlanner.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/NereidsPlanner.java index 4eafa0e2172f96..eb041a36f6e27b 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/NereidsPlanner.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/NereidsPlanner.java @@ -707,7 +707,9 @@ public String getExplainString(ExplainOptions explainOptions) { + rewrittenPlan.treeString() + "\n\n" + "========== OPTIMIZED PLAN " + getTimeMetricString(SummaryProfile::getPrettyNereidsOptimizeTime) + " ==========\n" - + optimizedPlan.treeString() + "\n\n"; + + optimizedPlan.treeString() + "\n\n" + + "========== MEMO " + + cascadesContext.getMemo().toString() + "\n\n"; if (distributedPlans != null && !distributedPlans.isEmpty()) { plan += "========== DISTRIBUTED PLAN " diff --git a/regression-test/framework/src/main/groovy/org/apache/doris/regression/suite/Suite.groovy b/regression-test/framework/src/main/groovy/org/apache/doris/regression/suite/Suite.groovy index f5d811514b375d..a6334d2622933f 100644 --- a/regression-test/framework/src/main/groovy/org/apache/doris/regression/suite/Suite.groovy +++ b/regression-test/framework/src/main/groovy/org/apache/doris/regression/suite/Suite.groovy @@ -71,6 +71,7 @@ import java.util.concurrent.Future import java.util.concurrent.ThreadFactory import java.util.concurrent.TimeUnit import java.util.concurrent.atomic.AtomicBoolean +import java.util.regex.Pattern import java.util.stream.Collectors import java.util.stream.LongStream import static org.apache.doris.regression.util.DataUtils.sortByToString @@ -1313,15 +1314,23 @@ class Suite implements GroovyInterceptable { } catch (Throwable t) { throw new IllegalStateException("Check tag '${tag}' failed, sql:\n${arg}", t) } - if (errorMsg != null) { + def allPlan = "" + if (arg instanceof String) { + def query = (String) arg; + def pattern = Pattern.compile("^\\s*explain\\s+shape\\s*plan\\s*", Pattern.MULTILINE) + if (query =~ pattern) { + def physical = query.replaceAll(pattern, "explain all plan ") + allPlan = JdbcUtils.executeToStringList(context.getConnection(), physical)[0].join('\n') + } + } + String csvRealResult = realResults.stream() .map {row -> OutputUtils.toCsvString(row)} .collect(Collectors.joining("\n")) def outputFilePath = context.outputFile.getCanonicalPath().substring(context.config.dataPath.length() + 1) def line = expectCsvResults.currentLine() logger.warn("expect results in file: ${outputFilePath}, line: ${line}\nrealResults:\n" + csvRealResult) - throw new IllegalStateException("Check tag '${tag}' failed:\n${errorMsg}\n\nsql:\n${arg}") - } + throw new IllegalStateException("Check tag '${tag}' failed:\n${errorMsg}\n\nsql:\n${arg}\n\n${allPlan}") } } diff --git a/regression-test/suites/nereids_tpcds_shape_sf100_p0/shape/query35.groovy b/regression-test/suites/nereids_tpcds_shape_sf100_p0/shape/query35.groovy index 9d8ccc9e339a3d..02e2bd3398514b 100644 --- a/regression-test/suites/nereids_tpcds_shape_sf100_p0/shape/query35.groovy +++ b/regression-test/suites/nereids_tpcds_shape_sf100_p0/shape/query35.groovy @@ -92,7 +92,7 @@ suite("query35") { cd_dep_college_count limit 100""" qt_ds_shape_35 """ - explain shape plan + explain physical plan ${ds} """ }