private void rewriteSelectWithoutGroupBy(SelectBlock selectBlock) throws CompilationException { if (hasSql92Aggregate(selectBlock)) { // Adds an implicit group-by clause for SQL-92 global aggregate. List<GbyVariableExpressionPair> gbyPairList = new ArrayList<>(); List<GbyVariableExpressionPair> decorPairList = new ArrayList<>(); VariableExpr groupVar = new VariableExpr(context.newVariable()); groupVar.setSourceLocation(selectBlock.getSourceLocation()); List<Pair<Expression, Identifier>> groupFieldList = createGroupFieldList(selectBlock); GroupbyClause gbyClause = new GroupbyClause(gbyPairList, decorPairList, new HashMap<>(), groupVar, groupFieldList, false, true); gbyClause.setSourceLocation(selectBlock.getSourceLocation()); selectBlock.setGroupbyClause(gbyClause); } }
GroupbyClause copy = new GroupbyClause(gbyPairList, decorPairList, withVarMap, groupVarExpr, groupFieldList, gc.hasHashGroupByHint(), gc.isGroupAll()); copy.setSourceLocation(gc.getSourceLocation());
@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); }
final public GroupbyClause GroupbyClause() throws ParseException, ParseException { Token startToken = null; GroupbyClause gbc = new GroupbyClause(); List<GbyVariableExpressionPair> vePairList = new ArrayList<GbyVariableExpressionPair>(); VariableExpr var = null;
final public Clause GroupClause() throws ParseException, ParseException { GroupbyClause gbc = new GroupbyClause();
final public Clause GroupClause() throws ParseException, ParseException { GroupbyClause gbc = new GroupbyClause();