MCPcopy
hub / github.com/uber/aresdb / VisitLogicalBinary

Method VisitLogicalBinary

query/sql/sql_parser.go:660–700  ·  view source on GitHub ↗

VisitLogicalBinary visits the node

(ctx *antlrgen.LogicalBinaryContext)

Source from the content-addressed store, hash-verified

658
659// VisitLogicalBinary visits the node
660func (v *ASTBuilder) VisitLogicalBinary(ctx *antlrgen.LogicalBinaryContext) interface{} {
661 location := v.getLocation(ctx)
662 if v.SQL2AqlCtx.exprCheck {
663 v.Logger.Debugf("VisitLogicalBinary check: %s", ctx.GetText())
664 if ctx.GetOperator() == nil {
665 panic(fmt.Errorf("missing logicalBinary operator, (line:%d, col:%d)",
666 location.Line, location.CharPosition))
667 }
668
669 v.Visit(ctx.GetLeft())
670 v.Visit(ctx.GetRight())
671 return tree.NewExpression(v.getLocation(ctx))
672 }
673
674 v.Logger.Debugf("VisitLogicalBinary: %s", ctx.GetText())
675 operator := v.getLogicalBinaryOperator(ctx.GetOperator().GetTokenType())
676 if operator == tree.OR {
677 if v.SQL2AqlCtx.exprOrigin == ExprOriginWhere {
678 v.SQL2AqlCtx.MapRowFilters[v.SQL2AqlCtx.mapKey] =
679 append(v.SQL2AqlCtx.MapRowFilters[v.SQL2AqlCtx.mapKey], v.getText(ctx.BaseParserRuleContext))
680 } else if v.SQL2AqlCtx.exprOrigin == ExprOriginJoinOn {
681 last := len(v.SQL2AqlCtx.MapJoinTables[v.SQL2AqlCtx.mapKey]) - 1
682 v.SQL2AqlCtx.MapJoinTables[v.SQL2AqlCtx.mapKey][last].Conditions =
683 append(v.SQL2AqlCtx.MapJoinTables[v.SQL2AqlCtx.mapKey][last].Conditions, v.getText(ctx.BaseParserRuleContext))
684 }
685
686 expr := tree.NewExpression(v.getLocation(ctx))
687 expr.SetValue(fmt.Sprintf("LogicalBinaryExpression: (%s)", v.getText(ctx.BaseParserRuleContext)))
688 return expr
689 }
690
691 left, _ := v.Visit(ctx.GetLeft()).(tree.IExpression)
692 right, _ := v.Visit(ctx.GetRight()).(tree.IExpression)
693 logicalBinaryExpr := tree.NewLogicalBinaryExpression(
694 v.getLocation(ctx),
695 operator,
696 left,
697 right)
698 logicalBinaryExpr.SetValue(fmt.Sprintf("LogicalBinaryExpression: (%s)", v.getText(ctx.BaseParserRuleContext)))
699 return logicalBinaryExpr
700}
701
702// VisitBooleanDefault visits the node
703func (v *ASTBuilder) VisitBooleanDefault(ctx *antlrgen.BooleanDefaultContext) interface{} {

Callers

nothing calls this directly

Calls 12

getLocationMethod · 0.95
VisitMethod · 0.95
getTextMethod · 0.95
NewExpressionFunction · 0.92
DebugfMethod · 0.65
ErrorfMethod · 0.65
SetValueMethod · 0.65
GetOperatorMethod · 0.45
GetLeftMethod · 0.45
GetRightMethod · 0.45

Tested by

no test coverage detected