MCPcopy Create free account
hub / github.com/brimdata/super / sqlJoin

Method sqlJoin

compiler/semantic/sql.go:576–607  ·  view source on GitHub ↗

For now, each joining table is on the right... We don't have logic to not care about the side of the JOIN ON keys...

(join *ast.SQLJoin, seq sem.Seq)

Source from the content-addressed store, hash-verified

574// For now, each joining table is on the right...
575// We don't have logic to not care about the side of the JOIN ON keys...
576func (t *translator) sqlJoin(join *ast.SQLJoin, seq sem.Seq) (sem.Seq, relScope) {
577 if len(seq) > 0 {
578 // At some point we might want to let parent data flow into a join somehow,
579 // but for now we flag an error.
580 t.error(join, errors.New("SQL join cannot inherit data from pipeline parent"))
581 }
582 leftSeq, leftScope := t.sqlTableExpr(join.Left, nil)
583 rightSeq, rightScope := t.sqlTableExpr(join.Right, nil)
584 var scope relScope
585 if using, ok := join.Cond.(*ast.JoinUsingCond); ok {
586 scope = newJoinUsingScope(&joinScope{left: leftScope, right: rightScope}, idsToStrings(using.Fields))
587 } else {
588 scope = &joinScope{left: leftScope, right: rightScope}
589 }
590 saved := t.scope.sql
591 t.scope.sql = scope
592 cond := t.sqlJoinCond(join.Cond, scope.superType(t.sctx, t.checker.unknown))
593 t.scope.sql = saved
594 style := join.Style
595 if style == "" {
596 style = "inner"
597 }
598 par := &sem.ForkOp{Paths: []sem.Seq{leftSeq, rightSeq}}
599 dagJoin := &sem.JoinOp{
600 Node: join,
601 Style: style,
602 LeftAlias: "left",
603 RightAlias: "right",
604 Cond: cond,
605 }
606 return sem.Seq{par, dagJoin}, scope
607}
608
609func (t *translator) sqlJoinCond(cond ast.JoinCond, typ super.Type) sem.Expr {
610 switch cond := cond.(type) {

Callers 1

sqlTableExprMethod · 0.95

Calls 7

sqlTableExprMethod · 0.95
sqlJoinCondMethod · 0.95
superTypeMethod · 0.95
newJoinUsingScopeFunction · 0.85
idsToStringsFunction · 0.85
NewMethod · 0.80
errorMethod · 0.45

Tested by

no test coverage detected