MCPcopy Create free account
hub / github.com/AfterShip/clickhouse-sql-parser / parseWithClause

Method parseWithClause

parser/parser_query.go:17–40  ·  view source on GitHub ↗
(pos Pos)

Source from the content-addressed store, hash-verified

15}
16
17func (p *Parser) parseWithClause(pos Pos) (*WithClause, error) {
18 if err := p.expectKeyword(KeywordWith); err != nil {
19 return nil, err
20 }
21
22 cteExpr, err := p.parseCTEStmt(p.Pos())
23 if err != nil {
24 return nil, err
25 }
26 ctes := []*CTEStmt{cteExpr}
27 for p.tryConsumeTokenKind(TokenKindComma) != nil {
28 cteExpr, err := p.parseCTEStmt(p.Pos())
29 if err != nil {
30 return nil, err
31 }
32 ctes = append(ctes, cteExpr)
33 }
34
35 return &WithClause{
36 WithPos: pos,
37 CTEs: ctes,
38 EndPos: ctes[len(ctes)-1].End(),
39 }, nil
40}
41
42func (p *Parser) tryParseTopClause(pos Pos) (*TopClause, error) {
43 if !p.matchKeyword(KeywordTop) {

Callers 1

tryParseWithClauseMethod · 0.95

Calls 5

expectKeywordMethod · 0.95
parseCTEStmtMethod · 0.95
PosMethod · 0.95
tryConsumeTokenKindMethod · 0.95
EndMethod · 0.65

Tested by

no test coverage detected