Skip to content

Commit c913ae2

Browse files
author
James Cor
committed
add inner joins too
1 parent e40746c commit c913ae2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

sql/analyzer/replace_sort.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,9 @@ func replaceIdxSortHelper(ctx *sql.Context, scope *plan.Scope, node sql.Node, so
154154
*plan.Project, *plan.Filter, *plan.Limit, *plan.Offset, *plan.Distinct, *plan.TableAlias:
155155
newChildren[i], same, err = replaceIdxSortHelper(ctx, scope, child, sortNode)
156156
case *plan.JoinNode:
157-
// TODO: is this applicable to other types of joins?
158-
// as long as left child is already sorted and SortFields are a prefix, then it's ok?
159-
if !c.JoinType().IsMerge() && !c.JoinType().IsCross() {
157+
// Merge Joins assume that left and right are sorted
158+
// Cross Joins and Inner Joins don't care if
159+
if !c.JoinType().IsMerge() && !c.JoinType().IsCross() && !c.JoinType().IsInner() {
160160
continue
161161
}
162162
// It's (probably) not possible to have Sort as child of Join without Subquery/SubqueryAlias,

0 commit comments

Comments
 (0)