Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
systay committed Sep 5, 2024
1 parent c16fa1e commit 3908a68
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
18 changes: 18 additions & 0 deletions go/vt/vtgate/planbuilder/operators/expressions.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,24 @@ func breakExpressionInLHSandRHS(
return
}

func valuesJoinExpressionSplit(ctx *plancontext.PlanningContext, expr sqlparser.Expr, lhs semantics.TableSet, tableName string) (lhsExprs sqlparser.Exprs, rhsExpr sqlparser.Expr) {
rhsExpr = sqlparser.CopyOnRewrite(expr, nil, func(cursor *sqlparser.CopyOnWriteCursor) {
nodeExpr, ok := cursor.Node().(sqlparser.Expr)
if !ok || !mustFetchFromInput(ctx, nodeExpr) {
return
}

deps := ctx.SemTable.RecursiveDeps(nodeExpr)
if !deps.IsSolvedBy(lhs) {
return
}

lhsExprs = append(lhsExprs, nodeExpr)

}, ctx.SemTable.CopySemanticInfo).(sqlparser.Expr)
return
}

// nothingNeedsFetching will return true if all the nodes in the expression are constant
func nothingNeedsFetching(ctx *plancontext.PlanningContext, expr sqlparser.Expr) (constant bool) {
constant = true
Expand Down
3 changes: 3 additions & 0 deletions go/vt/vtgate/planbuilder/operators/route_planning.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,9 @@ func requiresSwitchingSides(ctx *plancontext.PlanningContext, op Operator) (requ
return
}

// select 1 from user u join user_extra ue on ue.id = u.id
// ue.id = ::u_id

// Will create a join valid for the current mysql version
func createJoin(ctx *plancontext.PlanningContext, lhs, rhs Operator, joinType sqlparser.JoinType, joinPredicates []sqlparser.Expr) (join JoinOp) {
sigOk := ctx.SemTable.QuerySignature.EmptySet()
Expand Down
2 changes: 1 addition & 1 deletion go/vt/vtgate/planbuilder/testdata/onecase.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[
{
"comment": "Add your test case here for debugging and run go test -run=One.",
"query": "",
"query": "select 1 from user u join user_extra ue on u.foo = ue.user_id",
"plan": {
}
}
Expand Down

0 comments on commit 3908a68

Please sign in to comment.