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

Method VisitSingleGroupingSet

query/sql/sql_parser.go:574–608  ·  view source on GitHub ↗

VisitSingleGroupingSet visits the node

(ctx *antlrgen.SingleGroupingSetContext)

Source from the content-addressed store, hash-verified

572
573// VisitSingleGroupingSet visits the node
574func (v *ASTBuilder) VisitSingleGroupingSet(ctx *antlrgen.SingleGroupingSetContext) interface{} {
575 v.Logger.Debugf("VisitSingleGroupingSet: %s", ctx.GetText())
576
577 level, levelWith, levelQuery := v.getCtxLevels(v.SQL2AqlCtx)
578 v.setCtxLevels(v.SQL2AqlCtx, level, levelWith, levelQuery)
579
580 ctxArr := ctx.GroupingExpressions().(*antlrgen.GroupingExpressionsContext).AllExpression()
581 columns := make([]tree.IExpression, len(ctxArr))
582 offset := len(v.SQL2AqlCtx.MapDimensions[v.SQL2AqlCtx.mapKey])
583 for i, c := range ctxArr {
584 v.SQL2AqlCtx.exprCheck = true
585 v.Visit(c)
586 v.SQL2AqlCtx.exprCheck = false
587 columns[i], _ = v.Visit(c).(tree.IExpression)
588 alias, expr := v.lookupSQLExpr(v.SQL2AqlCtx, v.SQL2AqlCtx.mapKey, util.GetSubstring(columns[i].GetValue()))
589 if len(v.SQL2AqlCtx.MapDimensions[v.SQL2AqlCtx.mapKey])-offset == i {
590 // timeBucket or numbericBucket is added into
591 // v.SQL2AqlCtx.MapDimensions[v.SQL2AqlCtx.mapKey] via visitFunctionCall
592 v.SQL2AqlCtx.MapDimensions[v.SQL2AqlCtx.mapKey] =
593 append(v.SQL2AqlCtx.MapDimensions[v.SQL2AqlCtx.mapKey],
594 queryCom.Dimension{
595 Alias: alias,
596 Expr: expr,
597 })
598 }
599 }
600
601 simpleGroupBy := tree.NewSimpleGroupBy(
602 v.getLocation(ctx),
603 columns)
604 simpleGroupBy.SetValue(fmt.Sprintf("SimpleGroupBy: (%s)", v.getText(ctx.BaseParserRuleContext)))
605
606 v.setCtxLevels(v.SQL2AqlCtx, level-1, levelWith, levelQuery)
607 return simpleGroupBy
608}
609
610// VisitSortItem visits the node
611func (v *ASTBuilder) VisitSortItem(ctx *antlrgen.SortItemContext) interface{} {

Callers

nothing calls this directly

Calls 13

getCtxLevelsMethod · 0.95
setCtxLevelsMethod · 0.95
VisitMethod · 0.95
lookupSQLExprMethod · 0.95
getLocationMethod · 0.95
getTextMethod · 0.95
GetSubstringFunction · 0.92
NewSimpleGroupByFunction · 0.92
DebugfMethod · 0.65
GetValueMethod · 0.65
SetValueMethod · 0.65
AllExpressionMethod · 0.45

Tested by

no test coverage detected