(e dag.Expr, leftAlias, rightAlias string)
| 130 | } |
| 131 | |
| 132 | func 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. |
no test coverage detected