parseTrinoSQL parses the given SQL using the omni Trino parser and returns one *omniAST per non-empty segment (empty / comment-only segments are skipped). On the first parse error it returns a *base.SyntaxError with the position translated into the coordinates of the original input. This mirrors th
(statement string)
| 76 | // translated into the coordinates of the original input. This mirrors the |
| 77 | // historical ParseTrino signature shape used by other files in this package. |
| 78 | func parseTrinoSQL(statement string) ([]*omniAST, error) { |
| 79 | stmts, err := SplitSQL(statement) |
| 80 | if err != nil { |
| 81 | return nil, err |
| 82 | } |
| 83 | |
| 84 | var result []*omniAST |
| 85 | for _, stmt := range stmts { |
| 86 | parsed, err := parseSegment(stmt) |
| 87 | if err != nil { |
| 88 | return nil, err |
| 89 | } |
| 90 | if parsed != nil { |
| 91 | result = append(result, parsed) |
| 92 | } |
| 93 | } |
| 94 | return result, nil |
| 95 | } |
| 96 | |
| 97 | // parseSegment parses a single already-split statement segment into an |
| 98 | // *omniAST. A blank or comment-only segment yields (nil, nil) so callers can |