Skip to content

Commit

Permalink
refactor: improve code prettiness
Browse files Browse the repository at this point in the history
Signed-off-by: Manan Gupta <[email protected]>
  • Loading branch information
GuptaManan100 committed Mar 20, 2024
1 parent bc713aa commit fca5ba9
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions go/vt/vtgate/planbuilder/operators/SQL_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,20 +222,18 @@ func (qb *queryBuilder) joinWith(other *queryBuilder, onCondition sqlparser.Expr
sel.SelectExprs = append(sel.SelectExprs, otherSel.SelectExprs...)
}

qb.mergeWhereClauses(stmt, otherStmt)

var newFromClause []sqlparser.TableExpr
switch joinType {
case sqlparser.NormalJoinType:
newFromClause = append(stmt.GetFrom(), otherStmt.GetFrom()...)
qb.addPredicate(onCondition)
default:
newFromClause = []sqlparser.TableExpr{buildJoin(stmt, otherStmt, onCondition, joinType)}
}

stmt.SetFrom(newFromClause)
qb.mergeWhereClauses(stmt, otherStmt)

if joinType == sqlparser.NormalJoinType {
qb.addPredicate(onCondition)
}
}

func (qb *queryBuilder) mergeWhereClauses(stmt, otherStmt FromStatement) {
Expand Down

0 comments on commit fca5ba9

Please sign in to comment.