Skip to content

Commit a28b09d

Browse files
authored
Merge pull request #3235 from dolthub/nicktobey/join_fix
Allow caching subqueries in a tree of joins.
2 parents 0afe2a9 + b82be99 commit a28b09d

File tree

2 files changed

+82
-2
lines changed

2 files changed

+82
-2
lines changed

enginetest/queries/query_plans.go

Lines changed: 78 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sql/analyzer/resolve_subqueries.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,10 @@ func cacheSubqueryAliasesInJoins(ctx *sql.Context, a *Analyzer, n sql.Node, scop
299299
var isMax1Row bool
300300
switch n := n.(type) {
301301
case *plan.JoinNode:
302-
inJoin = true
303-
leftChild = true
302+
if !inJoin {
303+
inJoin = true
304+
leftChild = true
305+
}
304306
case *plan.SubqueryAlias:
305307
isCacheableSq = n.CanCacheResults() && !leftChild
306308
case *plan.CachedResults:

0 commit comments

Comments
 (0)