Skip to content

Commit

Permalink
undo planner and semantics changes
Browse files Browse the repository at this point in the history
Signed-off-by: Andres Taylor <andres@planetscale.com>
  • Loading branch information
systay committed Feb 11, 2025
1 parent c3de176 commit bf96f0e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
16 changes: 8 additions & 8 deletions go/vt/vtgate/planbuilder/operators/route_planning.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,12 +375,14 @@ func findColumnVindex(ctx *plancontext.PlanningContext, a Operator, exp sqlparse
// can be solved by any table in our routeTree. If an equality expression can be solved,
// we check if the equality expression and our table share the same vindex, if they do:
// the method will return the associated vindexes.SingleColumn.
_ = ctx.SemTable.ForEachExprEquality(exp, func(e sqlparser.Expr) error {
col, isCol := e.(*sqlparser.ColName)
for _, expr := range ctx.SemTable.GetExprAndEqualities(exp) {
col, isCol := expr.(*sqlparser.ColName)
if !isCol {
return nil
continue
}
deps := ctx.SemTable.RecursiveDeps(col)

deps := ctx.SemTable.RecursiveDeps(expr)

_ = Visit(a, func(rel Operator) error {
to, isTableOp := rel.(tableIDIntroducer)
if !isTableOp {
Expand All @@ -406,12 +408,10 @@ func findColumnVindex(ctx *plancontext.PlanningContext, a Operator, exp sqlparse
}
return nil
})

if singCol != nil {
return io.EOF
return singCol
}
return nil
})
}

return singCol
}
Expand Down
16 changes: 7 additions & 9 deletions go/vt/vtgate/planbuilder/operators/sharded_routing.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package operators

import (
"fmt"
"io"
"slices"

"vitess.io/vitess/go/mysql/collations"
Expand Down Expand Up @@ -722,18 +721,17 @@ func tryMergeShardedRouting(
}

// makeEvalEngineExpr transforms the given sqlparser.Expr into an evalengine expression
func makeEvalEngineExpr(ctx *plancontext.PlanningContext, n sqlparser.Expr) (result evalengine.Expr) {
_ = ctx.SemTable.ForEachExprEquality(n, func(expr sqlparser.Expr) error {
result, _ = evalengine.Translate(expr, &evalengine.Config{
func makeEvalEngineExpr(ctx *plancontext.PlanningContext, n sqlparser.Expr) evalengine.Expr {
for _, expr := range ctx.SemTable.GetExprAndEqualities(n) {
ee, _ := evalengine.Translate(expr, &evalengine.Config{
Collation: ctx.SemTable.Collation,
ResolveType: ctx.TypeForExpr,
Environment: ctx.VSchema.Environment(),
})
if result != nil {
return io.EOF
if ee != nil {
return ee
}
return nil
})
}

return
return nil
}
2 changes: 1 addition & 1 deletion go/vt/vtgate/semantics/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ func (a *analyzer) analyze(statement sqlparser.Statement) error {
}

func (a *analyzer) lateAnalyze(statement sqlparser.SQLNode) error {
_ = sqlparser.RewriteWithPath(statement, a.analyzeDown, a.analyzeUp)
_ = sqlparser.Rewrite(statement, a.analyzeDown, a.analyzeUp)
return a.err
}

Expand Down

0 comments on commit bf96f0e

Please sign in to comment.