MCPcopy Index your code
hub / github.com/bytebase/bytebase / parseRedshiftStatements

Function parseRedshiftStatements

backend/plugin/parser/redshift/redshift.go:15–48  ·  view source on GitHub ↗

parseRedshiftStatements is the ParseStatementsFunc for Redshift. Returns []ParsedStatement with both text and AST populated.

(statement string)

Source from the content-addressed store, hash-verified

13// parseRedshiftStatements is the ParseStatementsFunc for Redshift.
14// Returns []ParsedStatement with both text and AST populated.
15func parseRedshiftStatements(statement string) ([]base.ParsedStatement, error) {
16 stmts, err := SplitSQL(statement)
17 if err != nil {
18 return nil, err
19 }
20
21 var result []base.ParsedStatement
22 for _, stmt := range stmts {
23 if stmt.Empty {
24 result = append(result, base.ParsedStatement{Statement: stmt})
25 continue
26 }
27
28 omniStmts, err := ParseRedshiftOmni(stmt.Text)
29 if err != nil {
30 return nil, convertOmniError(err, stmt)
31 }
32 for _, omniStmt := range omniStmts {
33 if omniStmt.Empty() {
34 continue
35 }
36 result = append(result, base.ParsedStatement{
37 Statement: stmt,
38 AST: &OmniAST{
39 Node: omniStmt.AST,
40 Text: stmt.Text,
41 StartPosition: stmt.Start,
42 },
43 })
44 }
45 }
46
47 return result, nil
48}

Callers

nothing calls this directly

Calls 3

ParseRedshiftOmniFunction · 0.85
SplitSQLFunction · 0.70
convertOmniErrorFunction · 0.70

Tested by

no test coverage detected