MCPcopy Create free account
hub / github.com/deepflowio/deepflow / ParseSQL

Method ParseSQL

server/querier/parse/parse.go:34–106  ·  view source on GitHub ↗

解析入口,解析结果写入Model

(sql string)

Source from the content-addressed store, hash-verified

32
33// 解析入口,解析结果写入Model
34func (p *Parser) ParseSQL(sql string) error {
35 // sql解析
36 stmt, err := sqlparser.Parse(sql)
37 if err != nil {
38 return err
39 }
40
41 pStmt := stmt.(*sqlparser.Select)
42 // From解析
43 if pStmt.From != nil {
44 fromErr := p.Engine.TransFrom(pStmt.From)
45 if fromErr != nil {
46 return fromErr
47 }
48 }
49
50 // DerivativeGroupBy解析
51 if pStmt.GroupBy != nil {
52 groupErr := p.Engine.TransDerivativeGroupBy(pStmt.GroupBy)
53 if groupErr != nil {
54 return groupErr
55 }
56 }
57
58 // Select解析
59 var selectErr error
60 if pStmt.SelectExprs != nil {
61 selectErr = p.Engine.TransSelect(pStmt.SelectExprs)
62 if selectErr != nil {
63 return selectErr
64 }
65 }
66
67 // Where 解析
68 if pStmt.Where != nil {
69 whereErr := p.Engine.TransWhere(pStmt.Where)
70 if whereErr != nil {
71 return whereErr
72 }
73 }
74
75 // GroupBy解析
76 if pStmt.GroupBy != nil {
77 groupErr := p.Engine.TransGroupBy(pStmt.GroupBy)
78 if groupErr != nil {
79 return groupErr
80 }
81 }
82
83 if pStmt.Having != nil {
84 havingErr := p.Engine.TransHaving(pStmt.Having)
85 if havingErr != nil {
86 return havingErr
87 }
88 }
89
90 // OrderBy解析
91 if pStmt.OrderBy != nil {

Callers 4

TestGetSqlFunction · 0.95
ExecuteQueryMethod · 0.95
ParseSlimitSqlMethod · 0.95
ParseWithSqlMethod · 0.95

Calls 8

TransFromMethod · 0.65
TransSelectMethod · 0.65
TransWhereMethod · 0.65
TransGroupByMethod · 0.65
TransHavingMethod · 0.65
TransOrderByMethod · 0.65
TransLimitMethod · 0.65

Tested by 1

TestGetSqlFunction · 0.76