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

Method parseJoinRightExpr

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

Source from the content-addressed store, hash-verified

280}
281
282func (p *Parser) parseJoinRightExpr(pos Pos) (expr Expr, err error) {
283 var rightExpr Expr
284 var modifiers []string
285 switch {
286 case p.tryConsumeKeywords(KeywordGlobal):
287 case p.tryConsumeKeywords(KeywordLocal):
288 case p.tryConsumeTokenKind(TokenKindComma) != nil:
289 return p.parseJoinExpr(p.Pos())
290 default:
291 modifiers = p.parseJoinOp(p.Pos())
292 }
293
294 if len(modifiers) != 0 && !p.matchKeyword(KeywordJoin) {
295 return nil, fmt.Errorf("expected JOIN, got %s", p.lastTokenKind())
296 }
297 if !p.tryConsumeKeywords(KeywordJoin) {
298 return nil, nil
299 }
300
301 modifiers = append(modifiers, KeywordJoin)
302
303 // Check if this is an ARRAY JOIN
304 if slices.Contains(modifiers, KeywordArray) {
305 // For ARRAY JOIN, parse column expression list instead of table expression
306 expr, err = p.parseColumnExprList(p.Pos())
307 if err != nil {
308 return nil, err
309 }
310
311 // ARRAY JOIN doesn't have constraints (ON/USING)
312 // try parse next join
313 rightExpr, err = p.parseJoinRightExpr(p.Pos())
314 if err != nil {
315 return nil, err
316 }
317 return &JoinExpr{
318 JoinPos: pos,
319 Left: expr,
320 Right: rightExpr,
321 Modifiers: modifiers,
322 Constraints: nil,
323 }, nil
324 }
325
326 expr, err = p.parseJoinTableExpr(p.Pos())
327 if err != nil {
328 return nil, err
329 }
330 constrains, err := p.tryParseJoinConstraints(p.Pos())
331 if err != nil {
332 return nil, err
333 }
334
335 // try parse next join
336 rightExpr, err = p.parseJoinRightExpr(p.Pos())
337 if err != nil {
338 return nil, err
339 }

Callers 1

parseJoinExprMethod · 0.95

Calls 11

tryConsumeKeywordsMethod · 0.95
tryConsumeTokenKindMethod · 0.95
parseJoinExprMethod · 0.95
PosMethod · 0.95
parseJoinOpMethod · 0.95
matchKeywordMethod · 0.95
lastTokenKindMethod · 0.95
parseColumnExprListMethod · 0.95
parseJoinTableExprMethod · 0.95
ContainsMethod · 0.80

Tested by

no test coverage detected