MCPcopy Create free account
hub / github.com/brimdata/super / equiJoinKeyExprs

Function equiJoinKeyExprs

compiler/optimizer/join.go:132–158  ·  view source on GitHub ↗
(e dag.Expr, leftAlias, rightAlias string)

Source from the content-addressed store, hash-verified

130}
131
132func equiJoinKeyExprs(e dag.Expr, leftAlias, rightAlias string) (left, right dag.Expr, ok bool) {
133 b, ok := e.(*dag.BinaryExpr)
134 if !ok || b.Op != "==" {
135 return nil, nil, false
136 }
137 lhsFirst, ok := firstThisPathComponent(b.LHS)
138 if !ok {
139 return nil, nil, false
140 }
141 rhsFirst, ok := firstThisPathComponent(b.RHS)
142 if !ok {
143 return nil, nil, false
144 }
145 lhs, rhs := b.LHS, b.RHS
146 if lhsFirst != leftAlias {
147 lhsFirst, rhsFirst = rhsFirst, lhsFirst
148 lhs, rhs = rhs, lhs
149 }
150 if lhsFirst != leftAlias || rhsFirst != rightAlias {
151 return nil, nil, false
152 }
153 // This next step will mutate the input expression, do a copy here.
154 lhs, rhs = dag.CopyExpr(lhs), dag.CopyExpr(rhs)
155 stripFirstThisPathComponent(lhs)
156 stripFirstThisPathComponent(rhs)
157 return lhs, rhs, true
158}
159
160// firstThisPathComponent returns the first component common to every dag.This.Path
161// in e and a Boolean indicating whether such a common first component exists.

Callers 1

replaceJoinWithHashJoinFunction · 0.85

Calls 3

CopyExprFunction · 0.92
firstThisPathComponentFunction · 0.85

Tested by

no test coverage detected