Skip to content

Commit

Permalink
Backport 17103 - join panic
Browse files Browse the repository at this point in the history
  • Loading branch information
tanjinx committed Oct 29, 2024
1 parent 6eda517 commit 374f4b7
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion go/vt/vtgate/semantics/early_rewriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,15 @@ func (r *earlyRewriter) fillInQualifiers(cursor *sqlparser.CopyOnWriteCursor) {
if !found {
panic("uh oh")
}
tbl := r.tables.Tables[ts.TableOffset()]
offset := ts.TableOffset()
if offset < 0 {
// this is a column that is not coming from a table - it's an alias introduced in a SELECT expression
// Example: select (1+1) as foo from bar order by foo
// we don't want to add a qualifier to foo here
cursor.Replace(sqlparser.NewColName(col.Name.String()))
return
}
tbl := r.tables.Tables[offset]
tblName, err := tbl.Name()
if err != nil {
panic(err)
Expand Down

0 comments on commit 374f4b7

Please sign in to comment.