isKeyOfAggregate returns true iff any of a's grouping keys is the same as the given primary-key sort order or an order-preserving function thereof.
(a *dag.AggregateOp, in order.SortKeys)
| 101 | // same as the given primary-key sort order or an order-preserving function |
| 102 | // thereof. |
| 103 | func isKeyOfAggregate(a *dag.AggregateOp, in order.SortKeys) bool { |
| 104 | if in.IsNil() { |
| 105 | return false |
| 106 | } |
| 107 | key := in[0].Key |
| 108 | for _, outputKeyExpr := range a.Keys { |
| 109 | groupingKey := fieldOf(outputKeyExpr.LHS) |
| 110 | if groupingKey.Equal(key) { |
| 111 | rhsExpr := outputKeyExpr.RHS |
| 112 | rhs := fieldOf(rhsExpr) |
| 113 | if rhs.Equal(key) || orderPreservingCall(rhsExpr, groupingKey) { |
| 114 | return true |
| 115 | } |
| 116 | } |
| 117 | } |
| 118 | return false |
| 119 | } |
| 120 | |
| 121 | func orderPreservingCall(e dag.Expr, key field.Path) bool { |
| 122 | if call, ok := e.(*dag.CallExpr); ok { |
no test coverage detected