private void mapOrderByColumns(ExecutionContext context) throws TypeMismatchException, NameResolutionException { if (this.orderByAttrs != null) { Iterator<CompiledSortCriterion> iter = this.orderByAttrs.iterator(); while (iter.hasNext()) { CompiledSortCriterion csc = iter.next(); // Ideally for replicated regions, the requirement that // projected columns should // contain order by fields ( directly or derivable on it), // is not needed. But for PR , the query gathers only projected // columns, so applying order by on the query node // will need order by values ( which we dont send). So this // restriction is needed. // Also if this restriction is assumed to be correct, then the order // by comparator can be optimized as // it does not need to keep the mapping of evaluated order by clause, // for comparison if (!csc.mapExpressionToProjectionField(this.projAttrs, context)) { this.hasUnmappedOrderByCols = true; } } } }
protected void modifyGroupByToOrderBy(boolean setDistinct, ExecutionContext context) throws TypeMismatchException, NameResolutionException { if (setDistinct) { this.distinct = setDistinct; } this.orderByAttrs = new ArrayList<CompiledSortCriterion>(this.groupBy.size()); int colIndex = 0; for (CompiledValue cv : this.groupBy) { CompiledSortCriterion csc = new CompiledSortCriterion(false, cv); csc.mapExpressionToProjectionField(projAttrs, context); this.orderByAttrs.add(csc); } this.groupBy = null; }
private void mapOriginalOrderByColumns(ExecutionContext context) throws AmbiguousNameException, TypeMismatchException, NameResolutionException { this.revertAggregateFunctionInProjection(); Iterator<CompiledSortCriterion> iter = this.originalOrderByClause.iterator(); while (iter.hasNext()) { CompiledSortCriterion csc = iter.next(); if (!csc.mapExpressionToProjectionField(this.projAttrs, context)) { throw new QueryInvalidException( "Query contains atleast one order by field which is not present in projected fields."); } } this.replaceAggregateFunctionInProjection(); }