MCPcopy Create free account
hub / github.com/bytebase/bytebase / findRightMostSelect

Function findRightMostSelect

backend/plugin/db/snowflake/query.go:131–149  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

129// result-pipe operator (->>) the consuming query's select. Returns nil for
130// non-query statements.
131func 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}

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected