Skip to content

Commit

Permalink
print all plan when shape check failed
Browse files Browse the repository at this point in the history
  • Loading branch information
englefly committed Dec 23, 2024
1 parent f01f759 commit 06b07e0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ suite("query35") {
cd_dep_college_count
limit 100"""
qt_ds_shape_35 """
explain shape plan
explain physical plan
${ds}
"""
}

0 comments on commit 06b07e0

Please sign in to comment.