findRightMostSelect returns the right-most SELECT of the outermost query: for set operations the last operand's select (recursing through nested set operations and parenthesized selects, which omni flattens), for the result-pipe operator (->>) the consuming query's select. Returns nil for non-query
(node omniast.Node)
| 129 | // result-pipe operator (->>) the consuming query's select. Returns nil for |
| 130 | // non-query statements. |
| 131 | func findRightMostSelect(node omniast.Node) *omniast.SelectStmt { |
| 132 | switch n := node.(type) { |
| 133 | case *omniast.SelectStmt: |
| 134 | return n |
| 135 | case *omniast.SetOperationStmt: |
| 136 | return findRightMostSelect(n.Right) |
| 137 | case *omniast.ResultScanStmt: |
| 138 | return findRightMostSelect(n.Query) |
| 139 | case *omniast.ShowStmt: |
| 140 | // SHOW ... ->> <query>: omni stores the piped statement on ShowStmt.Pipe; |
| 141 | // the row limit applies to that trailing query. |
| 142 | if n.Pipe != nil { |
| 143 | return findRightMostSelect(n.Pipe) |
| 144 | } |
| 145 | return nil |
| 146 | default: |
| 147 | return nil |
| 148 | } |
| 149 | } |
no outgoing calls
no test coverage detected