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

Function parseTrinoSQL

backend/plugin/parser/trino/trino.go:78–95  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

76// translated into the coordinates of the original input. This mirrors the
77// historical ParseTrino signature shape used by other files in this package.
78func 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

Callers 4

validateQueryFunction · 0.85
TestTrinoParserFunction · 0.85
TestParseSyntaxErrorFunction · 0.85

Calls 2

parseSegmentFunction · 0.85
SplitSQLFunction · 0.70

Tested by 3

TestTrinoParserFunction · 0.68
TestParseSyntaxErrorFunction · 0.68