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

Function parseDorisSQL

backend/plugin/parser/doris/doris.go:85–111  ·  view source on GitHub ↗

parseDorisSQL parses the given SQL statement using the omni Doris parser. Returns one *omniAST per non-empty segment (empty / comment-only segments are skipped). This retains the historical signature shape used by other doris package files; on the first parse error it returns a *base.SyntaxError wi

(statement string)

Source from the content-addressed store, hash-verified

83// files; on the first parse error it returns a *base.SyntaxError with the
84// position translated into the coordinates of the original input.
85func parseDorisSQL(statement string) ([]*omniAST, error) {
86 stmts, err := SplitSQL(statement)
87 if err != nil {
88 return nil, err
89 }
90
91 var result []*omniAST
92 for _, stmt := range stmts {
93 if stmt.Empty || strings.TrimSpace(stmt.Text) == "" {
94 continue
95 }
96 file, errs := parser.Parse(stmt.Text)
97 if len(errs) > 0 {
98 pe := errs[0]
99 return nil, convertParseError(stmt.Text, &pe, stmt.Start)
100 }
101 var node ast.Node
102 if file != nil && len(file.Stmts) > 0 {
103 node = file.Stmts[0]
104 }
105 result = append(result, &omniAST{
106 node: node,
107 startPos: stmt.Start,
108 })
109 }
110 return result, nil
111}
112
113// convertParseError converts an omni *parser.ParseError to a
114// *base.SyntaxError that sql_service.go recognises for structured

Callers 2

validateQueryFunction · 0.85
TestDorisSQLParserFunction · 0.85

Calls 2

SplitSQLFunction · 0.70
convertParseErrorFunction · 0.70

Tested by 1

TestDorisSQLParserFunction · 0.68