Skip to content

Commit

Permalink
[fix](Nereids) fix explain plan with sql cache (apache#39431)
Browse files Browse the repository at this point in the history
introduced by apache#38950, explain plan with sql cache will throw an
exception
```
errCode = 2, detailMessage = Cannot invoke "org.apache.doris.nereids.trees.plans.Plan.treeString()" because "this.optimizedPlan" is null
```
  • Loading branch information
924060929 authored Aug 16, 2024
1 parent b3d20e7 commit afa5684
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public Plan planWithLock(LogicalPlan plan, PhysicalProperties requireProperties,
if (plan instanceof LogicalSqlCache) {
rewrittenPlan = analyzedPlan = plan;
LogicalSqlCache logicalSqlCache = (LogicalSqlCache) plan;
physicalPlan = new PhysicalSqlCache(
optimizedPlan = physicalPlan = new PhysicalSqlCache(
logicalSqlCache.getQueryId(),
logicalSqlCache.getColumnLabels(), logicalSqlCache.getFieldInfos(),
logicalSqlCache.getResultExprs(), logicalSqlCache.getResultSetInFe(),
Expand Down
7 changes: 7 additions & 0 deletions regression-test/suites/query_p0/cache/sql_cache.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -244,4 +244,11 @@ suite("sql_cache") {
}

sql "ADMIN SET FRONTEND CONFIG ('cache_last_version_interval_second' = '10')"

// explain plan with sql cache
connect {
sql "set enable_sql_cache=true"
sql "select 100"
sql "explain plan select 100"
}
}

0 comments on commit afa5684

Please sign in to comment.