fe/src/main/java/com/cloudera/impala/analysis/AggregateInfo.java
/**
   * Returns descriptor for output tuples created by aggregation computation.
   * Also creates and register auxiliary equality predicates between the grouping slots
   * and the grouping exprs.
   */
Returns descriptor for output tuples created by aggregation computation.
Also creates and register auxiliary equality predicates between the grouping slots
and the grouping exprs.
Returns descriptor for output tuples created by aggregation computation . Also creates and register auxiliary equality predicates between the grouping slots and the grouping exprs .
public TupleDescriptor createAggTupleDesc(Analyzer analyzer)
      throws AuthorizationException {
    LOG.trace("createAggTupleDesc()");
    TupleDescriptor result = analyzer.getDescTbl().createTupleDescriptor();
    List<Expr> exprs = Lists.newLinkedList();
    exprs.addAll(groupingExprs_);
    exprs.addAll(aggregateExprs_);
    int aggregateExprStartIndex = groupingExprs_.size();
    for (int i = 0; i < exprs.size(); ++i) {
      Expr expr = exprs.get(i);
      SlotDescriptor outputSlotDesc = analyzer.addSlotDescriptor(result);
      outputSlotDesc.setLabel(expr.toSql());
      Preconditions.checkState(expr.getType().isValid());
      outputSlotDesc.setType(expr.getType());
      outputSlotDesc.setStats(ColumnStats.fromExpr(expr));
      LOG.trace(outputSlotDesc.debugString());
      if (i < aggregateExprStartIndex) {
        if (!expr.isConstant()) {
          analyzer.createAuxEquivPredicate(
              new SlotRef(outputSlotDesc), expr.clone(null));
        }
      } else {
        Preconditions.checkArgument(expr instanceof FunctionCallExpr);
        FunctionCallExpr aggExpr = (FunctionCallExpr)expr;
        if (aggExpr.getFnName().getFunction().equals("count")) {
          outputSlotDesc.setIsNullable(false);
        }
      }
      aggTupleSMap_.addMapping(expr.clone(null), new SlotRef(outputSlotDesc));
    }
    LOG.trace("aggtuple=" + result.debugString());
    LOG.trace("aggtuplesmap=" + aggTupleSMap_.debugString());
    return result;
  }
public TupleDescriptor createAggTupleDesc ( Analyzer analyzer ) throws AuthorizationException { LOG . trace ( "createAggTupleDesc()" ) ; TupleDescriptor result = analyzer . getDescTbl ( ) . createTupleDescriptor ( ) ; List < Expr > exprs = Lists . newLinkedList ( ) ; exprs . addAll ( groupingExprs_ ) ; exprs . addAll ( aggregateExprs_ ) ; int aggregateExprStartIndex = groupingExprs_ . size ( ) ; for ( int i = 0 ; i < exprs . size ( ) ; ++ i ) { Expr expr = exprs . get ( i ) ; SlotDescriptor outputSlotDesc = analyzer . addSlotDescriptor ( result ) ; outputSlotDesc . setLabel ( expr . toSql ( ) ) ; Preconditions . checkState ( expr . getType ( ) . isValid ( ) ) ; outputSlotDesc . setType ( expr . getType ( ) ) ; outputSlotDesc . setStats ( ColumnStats . fromExpr ( expr ) ) ; LOG . trace ( outputSlotDesc . debugString ( ) ) ; if ( i < aggregateExprStartIndex ) { if ( ! expr . isConstant ( ) ) { analyzer . createAuxEquivPredicate ( new SlotRef ( outputSlotDesc ) , expr . clone ( null ) ) ; } } else { Preconditions . checkArgument ( expr instanceof FunctionCallExpr ) ; FunctionCallExpr aggExpr = ( FunctionCallExpr ) expr ; if ( aggExpr . getFnName ( ) . getFunction ( ) . equals ( "count" ) ) { outputSlotDesc . setIsNullable ( false ) ; } } aggTupleSMap_ . addMapping ( expr . clone ( null ) , new SlotRef ( outputSlotDesc ) ) ; } LOG . trace ( "aggtuple=" + result . debugString ( ) ) ; LOG . trace ( "aggtuplesmap=" + aggTupleSMap_ . debugString ( ) ) ; return result ; }
Returns descriptor for output tuples created by aggregation computation.
Returns descriptor for output tuples created by aggregation computation .
// count(*) is non-nullable. // register equivalence between grouping slot and grouping expr; // do this only when the grouping expr isn't a constant, otherwise // it'll simply show up as a gratuitous HAVING predicate // (which would actually be incorrect of the constant happens to be NULL)