(_ Pos)
| 975 | } |
| 976 | |
| 977 | func (p *Parser) parseSelectQuery(_ Pos) (*SelectQuery, error) { |
| 978 | if !p.matchKeyword(KeywordSelect) && !p.matchKeyword(KeywordWith) && !p.matchTokenKind(TokenKindLParen) { |
| 979 | return nil, fmt.Errorf("expected SELECT, WITH or (, got %s", p.lastTokenKind()) |
| 980 | } |
| 981 | |
| 982 | hasParen := p.tryConsumeTokenKind(TokenKindLParen) != nil |
| 983 | selectStmt, err := p.parseSelectStmt(p.Pos()) |
| 984 | if err != nil { |
| 985 | return nil, err |
| 986 | } |
| 987 | switch { |
| 988 | case p.tryConsumeKeywords(KeywordUnion): |
| 989 | switch { |
| 990 | case p.tryConsumeKeywords(KeywordAll): |
| 991 | unionAllExpr, err := p.parseSelectQuery(p.Pos()) |
| 992 | if err != nil { |
| 993 | return nil, err |
| 994 | } |
| 995 | selectStmt.UnionAll = unionAllExpr |
| 996 | case p.tryConsumeKeywords(KeywordDistinct): |
| 997 | unionDistinctExpr, err := p.parseSelectQuery(p.Pos()) |
| 998 | if err != nil { |
| 999 | return nil, err |
| 1000 | } |
| 1001 | selectStmt.UnionDistinct = unionDistinctExpr |
| 1002 | default: |
| 1003 | return nil, fmt.Errorf("expected ALL or DISTINCT, got %s", p.lastTokenKind()) |
| 1004 | } |
| 1005 | case p.tryConsumeKeywords(KeywordExcept): |
| 1006 | exceptExpr, err := p.parseSelectQuery(p.Pos()) |
| 1007 | if err != nil { |
| 1008 | return nil, err |
| 1009 | } |
| 1010 | selectStmt.Except = exceptExpr |
| 1011 | } |
| 1012 | if hasParen { |
| 1013 | if err := p.expectTokenKind(TokenKindRParen); err != nil { |
| 1014 | return nil, err |
| 1015 | } |
| 1016 | } |
| 1017 | return selectStmt, nil |
| 1018 | } |
| 1019 | |
| 1020 | func (p *Parser) parseSelectStmt(pos Pos) (*SelectQuery, error) { // nolint: funlen |
| 1021 | withClause, err := p.tryParseWithClause(pos) |
no test coverage detected