Skip to content

Commit

Permalink
when check shape failed, print all plan with memo
Browse files Browse the repository at this point in the history
  • Loading branch information
englefly committed Dec 23, 2024
1 parent 82d021b commit 7a82825
Show file tree
Hide file tree
Showing 3 changed files with 16 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 @@ -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}")
}
}

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 7a82825

Please sign in to comment.