public static List<VariableExpr> getBindingVariables(GroupbyClause gbyClause) { List<VariableExpr> bindingVars = new ArrayList<>(); if (gbyClause == null) { return bindingVars; } for (GbyVariableExpressionPair gbyKey : gbyClause.getGbyPairList()) { VariableExpr var = gbyKey.getVar(); if (var != null) { bindingVars.add(var); } } if (gbyClause.hasDecorList()) { for (GbyVariableExpressionPair gbyKey : gbyClause.getDecorPairList()) { VariableExpr var = gbyKey.getVar(); if (var != null) { bindingVars.add(var); } } } if (gbyClause.hasWithMap()) { bindingVars.addAll(gbyClause.getWithVarMap().values()); } bindingVars.add(gbyClause.getGroupVar()); return bindingVars; }
private void getGroupBindings(GroupbyClause groupbyClause, List<FieldBinding> outFieldBindings, Set<String> outFieldNames) throws CompilationException { for (GbyVariableExpressionPair pair : groupbyClause.getGbyPairList()) { outFieldBindings.add(getFieldBinding(pair.getVar(), outFieldNames)); } if (groupbyClause.hasGroupVar()) { outFieldBindings.add(getFieldBinding(groupbyClause.getGroupVar(), outFieldNames)); } if (groupbyClause.hasWithMap()) { // no WITH in SQLPP throw new CompilationException(ErrorCode.COMPILATION_ILLEGAL_STATE, groupbyClause.getSourceLocation(), groupbyClause.getWithVarMap().values().toString()); } }
@Override public Pair<ILangExpression, VariableSubstitutionEnvironment> visit(GroupbyClause gc, VariableSubstitutionEnvironment env) throws CompilationException { VariableSubstitutionEnvironment newSubs = env; List<GbyVariableExpressionPair> newGbyList = VariableCloneAndSubstitutionUtil.substInVarExprPair(context, gc.getGbyPairList(), newSubs, this); List<GbyVariableExpressionPair> newDecorList = gc.hasDecorList() ? VariableCloneAndSubstitutionUtil.substInVarExprPair(context, gc.getDecorPairList(), newSubs, this) : new ArrayList<>(); VariableExpr newGroupVar = null; if (gc.hasGroupVar()) { newGroupVar = generateNewVariable(context, gc.getGroupVar()); } Map<Expression, VariableExpr> newWithMap = new HashMap<>(); if (gc.hasWithMap()) { for (Entry<Expression, VariableExpr> entry : gc.getWithVarMap().entrySet()) { Expression newKeyVar = (Expression) entry.getKey().accept(this, env).first; VariableExpr newValueVar = generateNewVariable(context, entry.getValue()); newWithMap.put(newKeyVar, newValueVar); } } List<Pair<Expression, Identifier>> newGroupFieldList = gc.hasGroupFieldList() ? VariableCloneAndSubstitutionUtil.substInFieldList(gc.getGroupFieldList(), env, this) : null; GroupbyClause newGroup = new GroupbyClause(newGbyList, newDecorList, newWithMap, newGroupVar, newGroupFieldList, gc.hasHashGroupByHint(), gc.isGroupAll()); newGroup.setSourceLocation(gc.getSourceLocation()); return new Pair<>(newGroup, newSubs); }
gc.getGroupVar().accept(this, 0); if (gc.hasGroupFieldList()) { printFieldList(step + 1, gc.getGroupFieldList());
groupVarExpr = (VariableExpr) gc.getGroupVar().accept(this, arg);
Collection<VariableExpr> visibleVarsInCurrentScope = SqlppVariableUtil.getBindingVariables(groupbyClause); VariableExpr groupVar = groupbyClause.getGroupVar(); Map<Expression, Identifier> groupFieldVars = getGroupFieldVariables(groupbyClause);
VariableExpr groupVar = gc.getGroupVar(); addNewVarSymbolToScope(newScope, groupVar.getVar(), groupVar.getSourceLocation());
VariableExpr groupVar = gc.getGroupVar(); LogicalVariable groupLogicalVar = context.newVar(); NestedTupleSourceOperator ntsOp = new NestedTupleSourceOperator(new MutableObject<>(gOp));