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..f2eccb5c592ec3 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 @@ -1314,13 +1315,23 @@ class Suite implements GroovyInterceptable { 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")) + .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\nmemo:\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} """ }