Search in sources :

Example 1 with AggregateFunctionImpl

use of org.apache.calcite.schema.impl.AggregateFunctionImpl in project storm by apache.

the class RelNodeCompiler method aggregateResult.

private String aggregateResult(AggregateCall call, PrintWriter pw) {
    SqlAggFunction aggFunction = call.getAggregation();
    String aggregationName = call.getAggregation().getName();
    Type ty = typeFactory.getJavaClass(call.getType());
    String result;
    if (aggFunction instanceof SqlUserDefinedAggFunction) {
        AggregateFunction aggregateFunction = ((SqlUserDefinedAggFunction) aggFunction).function;
        result = doAggregateResult((AggregateFunctionImpl) aggregateFunction, reserveAggVarName(call), ty, pw);
    } else {
        List<BuiltinAggregateFunctions.TypeClass> typeClasses = BuiltinAggregateFunctions.TABLE.get(aggregationName);
        if (typeClasses == null) {
            throw new UnsupportedOperationException(aggregationName + " Not implemented");
        }
        result = doAggregateResult(AggregateFunctionImpl.create(findMatchingClass(aggregationName, typeClasses, ty)), reserveAggVarName(call), ty, pw);
    }
    return result;
}
Also used : RelDataType(org.apache.calcite.rel.type.RelDataType) Type(java.lang.reflect.Type) AggregateFunction(org.apache.calcite.schema.AggregateFunction) AggregateFunctionImpl(org.apache.calcite.schema.impl.AggregateFunctionImpl) SqlUserDefinedAggFunction(org.apache.calcite.sql.validate.SqlUserDefinedAggFunction) SqlAggFunction(org.apache.calcite.sql.SqlAggFunction)

Example 2 with AggregateFunctionImpl

use of org.apache.calcite.schema.impl.AggregateFunctionImpl in project streamline by hortonworks.

the class RelNodeCompiler method aggregateResult.

private String aggregateResult(AggregateCall call, PrintWriter pw) {
    SqlAggFunction aggFunction = call.getAggregation();
    String aggregationName = call.getAggregation().getName();
    Type ty = typeFactory.getJavaClass(call.getType());
    String result;
    if (aggFunction instanceof SqlUserDefinedAggFunction) {
        AggregateFunction aggregateFunction = ((SqlUserDefinedAggFunction) aggFunction).function;
        result = doAggregateResult((AggregateFunctionImpl) aggregateFunction, reserveAggVarName(call), ty, pw);
    } else {
        List<BuiltinAggregateFunctions.TypeClass> typeClasses = BuiltinAggregateFunctions.TABLE.get(aggregationName);
        if (typeClasses == null) {
            throw new UnsupportedOperationException(aggregationName + " Not implemented");
        }
        result = doAggregateResult(AggregateFunctionImpl.create(findMatchingClass(aggregationName, typeClasses, ty)), reserveAggVarName(call), ty, pw);
    }
    return result;
}
Also used : RelDataType(org.apache.calcite.rel.type.RelDataType) Type(java.lang.reflect.Type) AggregateFunction(org.apache.calcite.schema.AggregateFunction) AggregateFunctionImpl(org.apache.calcite.schema.impl.AggregateFunctionImpl) SqlUserDefinedAggFunction(org.apache.calcite.sql.validate.SqlUserDefinedAggFunction) SqlAggFunction(org.apache.calcite.sql.SqlAggFunction)

Aggregations

Type (java.lang.reflect.Type)2 RelDataType (org.apache.calcite.rel.type.RelDataType)2 AggregateFunction (org.apache.calcite.schema.AggregateFunction)2 AggregateFunctionImpl (org.apache.calcite.schema.impl.AggregateFunctionImpl)2 SqlAggFunction (org.apache.calcite.sql.SqlAggFunction)2 SqlUserDefinedAggFunction (org.apache.calcite.sql.validate.SqlUserDefinedAggFunction)2