*************** from clause ***************** VisitJoinRelation visits the node
(ctx *antlrgen.JoinRelationContext)
| 750 | |
| 751 | // VisitJoinRelation visits the node |
| 752 | func (v *ASTBuilder) VisitJoinRelation(ctx *antlrgen.JoinRelationContext) interface{} { |
| 753 | v.Logger.Debugf("VisitJoinRelation: %s", ctx.GetText()) |
| 754 | |
| 755 | location := v.getLocation(ctx) |
| 756 | level, levelWith, levelQuery := v.getCtxLevels(v.SQL2AqlCtx) |
| 757 | |
| 758 | v.setCtxLevels(v.SQL2AqlCtx, level, levelWith, levelQuery) |
| 759 | left, _ := v.Visit(ctx.GetLeft()).(tree.IRelation) |
| 760 | |
| 761 | var right tree.IRelation |
| 762 | if ctx.CROSS() != nil { |
| 763 | v.setCtxLevels(v.SQL2AqlCtx, level, levelWith, levelQuery) |
| 764 | right, _ = v.VisitSampledRelation(ctx.GetRight().(*antlrgen.SampledRelationContext)).(tree.IRelation) |
| 765 | join := tree.NewJoin(v.getLocation(ctx), tree.CROSS, left, right, nil) |
| 766 | join.SetValue(fmt.Sprintf("Join: (%s)", v.getText(ctx.BaseParserRuleContext))) |
| 767 | return join |
| 768 | } |
| 769 | |
| 770 | var criteria tree.IJoinCriteria |
| 771 | if ctx.NATURAL() != nil { |
| 772 | if levelQuery != 0 { |
| 773 | panic(fmt.Errorf("natural join not supported at subquery/withQuery at (line:%d, col:%d)", |
| 774 | location.Line, location.CharPosition)) |
| 775 | } |
| 776 | v.setCtxLevels(v.SQL2AqlCtx, level, levelWith, levelQuery) |
| 777 | right, _ = v.VisitSampledRelation(ctx.GetRight().(*antlrgen.SampledRelationContext)).(tree.IRelation) |
| 778 | criteria = tree.NewNaturalJoin() |
| 779 | } else { |
| 780 | v.setCtxLevels(v.SQL2AqlCtx, level, levelWith, levelQuery) |
| 781 | right, _ = v.Visit(ctx.GetRightRelation()).(tree.IRelation) |
| 782 | |
| 783 | ctxJoinCriteria, ok := ctx.JoinCriteria().(*antlrgen.JoinCriteriaContext) |
| 784 | if !ok { |
| 785 | panic(fmt.Errorf("missing join criteria at (line:%d, col:%d)", location.Line, location.CharPosition)) |
| 786 | } |
| 787 | if ctxJoinCriteria.ON() != nil { |
| 788 | v.setCtxLevels(v.SQL2AqlCtx, level, levelWith, levelQuery) |
| 789 | v.SQL2AqlCtx.exprCheck = true |
| 790 | v.Visit(ctx.JoinCriteria().(*antlrgen.JoinCriteriaContext). |
| 791 | BooleanExpression()) |
| 792 | v.SQL2AqlCtx.exprCheck = false |
| 793 | joinOn, _ := v.Visit(ctx.JoinCriteria().(*antlrgen.JoinCriteriaContext). |
| 794 | BooleanExpression()).(tree.IExpression) |
| 795 | criteria = tree.NewJoinOn(joinOn) |
| 796 | } else if ctxJoinCriteria.USING() != nil { |
| 797 | ctxArr := ctx.JoinCriteria().(*antlrgen.JoinCriteriaContext).AllIdentifier() |
| 798 | expressions := make([]*tree.Identifier, len(ctxArr)) |
| 799 | for i, c := range ctxArr { |
| 800 | expressions[i], _ = v.Visit(c).(*tree.Identifier) |
| 801 | } |
| 802 | criteria = tree.NewJoinUsing(expressions) |
| 803 | } |
| 804 | } |
| 805 | |
| 806 | joinType := v.getJoinType(ctx) |
| 807 | if joinType != tree.LEFT { |
| 808 | panic(fmt.Errorf("join type %v not supported yet at (line:%d, col:%d)", |
| 809 | tree.JoinTypes[joinType], location.Line, location.CharPosition)) |
nothing calls this directly
no test coverage detected