Skip to content

Commit

Permalink
Revert "subtask 10781 fix" (#11102)
Browse files Browse the repository at this point in the history
Reverts #11094

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
sukki37 and mergify[bot] authored Aug 8, 2023
1 parent 1a6850b commit da74d9c
Showing 1 changed file with 12 additions and 24 deletions.
36 changes: 12 additions & 24 deletions pkg/sql/compile/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -1738,22 +1738,12 @@ func (c *Compile) compileShuffleJoin(ctx context.Context, node, left, right *pla
}

parent, children := c.newShuffleJoinScopeList(lefts, rights, node)
if parent != nil {
lastOperator := make([]vm.Instruction, 0, len(children))
for i := range children {
ilen := len(children[i].Instructions) - 1
lastOperator = append(lastOperator, children[i].Instructions[ilen])
children[i].Instructions = children[i].Instructions[:ilen]
}

defer func() {
// recovery the children's last operator
for i := range children {
children[i].appendInstruction(lastOperator[i])
}
}()
lastOperator := make([]vm.Instruction, 0, len(children))
for i := range children {
ilen := len(children[i].Instructions) - 1
lastOperator = append(lastOperator, children[i].Instructions[ilen])
children[i].Instructions = children[i].Instructions[:ilen]
}

switch node.JoinType {
case plan.Node_INNER:
for i := range children {
Expand Down Expand Up @@ -1822,11 +1812,12 @@ func (c *Compile) compileShuffleJoin(ctx context.Context, node, left, right *pla
default:
panic(moerr.NewNYI(ctx, fmt.Sprintf("shuffle join do not support join typ '%v'", node.JoinType)))
}

if parent != nil {
return parent
// recovery the children's last operator
for i := range children {
children[i].appendInstruction(lastOperator[i])
}
return children

return parent
}

func (c *Compile) compileBroadcastJoin(ctx context.Context, node, left, right *plan.Node, ss []*Scope, children []*Scope) []*Scope {
Expand Down Expand Up @@ -2596,8 +2587,7 @@ func (c *Compile) newBroadcastJoinScopeList(ss []*Scope, children []*Scope, n *p
}

func (c *Compile) newShuffleJoinScopeList(left, right []*Scope, n *plan.Node) ([]*Scope, []*Scope) {
single := len(c.cnList) <= 1
var parent []*Scope
parent := make([]*Scope, 0, len(c.cnList))
children := make([]*Scope, 0, len(c.cnList))
lnum := len(left)
sum := lnum + len(right)
Expand All @@ -2617,9 +2607,7 @@ func (c *Compile) newShuffleJoinScopeList(left, right []*Scope, n *plan.Node) ([
}
}
children = append(children, ss...)
if !single {
parent = append(parent, c.newMergeRemoteScope(ss, n))
}
parent = append(parent, c.newMergeRemoteScope(ss, n))
}

currentFirstFlag := c.anal.isFirst
Expand Down

0 comments on commit da74d9c

Please sign in to comment.