Skip to content

Commit

Permalink
cherry pick of 15939 (#5177)
Browse files Browse the repository at this point in the history
  • Loading branch information
planetscale-actions-bot authored May 14, 2024
1 parent 80bb70b commit 5313ae9
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions go/vt/vtgate/semantics/binder.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,19 +382,17 @@ func (b *binder) searchInSelectExpressions(colName *sqlparser.ColName, deps depe
return dependency{certain: true, direct: direct, recursive: recursive, typ: typ}
}
}
if stmt.GroupBy != nil {
for _, gb := range stmt.GroupBy.Exprs {
selectCol, ok := gb.(*sqlparser.ColName)
if !ok || !selectCol.Name.Equal(colName.Name) {
continue
}
for _, gb := range stmt.GroupByExprs() {
selectCol, ok := gb.(*sqlparser.ColName)
if !ok || !selectCol.Name.Equal(colName.Name) {
continue
}

_, direct, _ := b.org.depsForExpr(selectCol)
if deps.direct == direct {
// we have found the ColName in the GROUP BY expressions, so it's safe to use here
direct, recursive, typ := b.org.depsForExpr(gb)
return dependency{certain: true, direct: direct, recursive: recursive, typ: typ}
}
_, direct, _ := b.org.depsForExpr(selectCol)
if deps.direct == direct {
// we have found the ColName in the GROUP BY expressions, so it's safe to use here
direct, recursive, typ := b.org.depsForExpr(gb)
return dependency{certain: true, direct: direct, recursive: recursive, typ: typ}
}
}
return dependency{}
Expand Down

0 comments on commit 5313ae9

Please sign in to comment.