Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
GuptaManan100 committed Oct 13, 2023
1 parent 5f84a3b commit a1c01cd
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions go/vt/vtgate/planbuilder/operators/query_planning.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"math/rand"
"time"
"unsafe"

"vitess.io/vitess/go/test/dbg"
"vitess.io/vitess/go/vt/sqlparser"
"vitess.io/vitess/go/vt/vtgate/planbuilder/operators/ops"
Expand Down Expand Up @@ -427,21 +428,21 @@ func exposeColumnsThroughDerivedTable(ctx *plancontext.PlanningContext, p *Proje
return
}

// If we didn't find it, and we are dealing with a ColName, we have to add it to the derived table
colExpr, ok := this.(*sqlparser.ColName)
if !ok {
return
}

// First we check if this expression is already being returned
for _, column := range cols {
if ctx.SemTable.EqualsExprWithDeps(column.Expr, this) {
col := sqlparser.NewColName(column.As.String())
if ctx.SemTable.EqualsExprWithDeps(column.Expr, colExpr) {
col := sqlparser.NewColName(column.ColumnName())
cursor.Replace(col)
return
}
}

// If we didn't find it, and we are dealing with a ColName, we have to add it to the derived table
colExpr, ok := this.(*sqlparser.ColName)
if !ok {
return
}

colAlias := fmt.Sprintf("%s_vt_%s_%s", p.DT.Alias, sqlparser.String(colExpr), RandString(2))

newCol := sqlparser.NewColName(colAlias)
Expand All @@ -463,20 +464,21 @@ func exposeColumnsThroughDerivedTable(ctx *plancontext.PlanningContext, p *Proje
return e, nil
}

for i, pred := range src.JoinPredicates {
x, err := pred.Map(f)
//for i, pred := range src.JoinPredicates {
// x, err := pred.Map(f)
// if err != nil {
// return err
// }
// src.JoinPredicates[i] = x
//}

for i, col := range src.JoinColumns {
var err error
src.JoinColumns[i], err = col.Map(f)
if err != nil {
return err
}
src.JoinPredicates[i] = x
}

// for i, col := range src.JoinColumns {
// src.JoinColumns[i], err = col.Map(f)
// if err != nil {
// return err
// }
// }
return nil
}

Expand Down

0 comments on commit a1c01cd

Please sign in to comment.