Search in sources :

Example 1 with RowDecodeType

use of com.huawei.boostkit.omnidata.decode.type.RowDecodeType in project boostkit-bigdata by kunpengcompute.

the class DataIoAdapter method extractAggregateFunction.

private void extractAggregateFunction(AggregateFunction aggregateFunction, Map<String, AggregationInfo.AggregateFunction> aggregationMap) {
    List<Expression> expressions = JavaConverters.seqAsJavaList(aggregateFunction.children());
    String aggregateFunctionName = aggregateFunction.toString();
    Type prestoType = NdpUtils.transOlkDataType(aggregateFunction.dataType(), false);
    AggregateFunctionType aggregateFunctionType = AggregateFunctionType.valueOf(aggregateFunction.getClass().getSimpleName());
    for (Expression expression : expressions) {
        if (!(expression instanceof Literal)) {
            omnidataProjections.add(createAggProjection(expression));
            int projectionId = fieldMap.size();
            fieldMap.put(aggregateFunctionName, projectionId);
            if (aggregateFunctionType.equals(AggregateFunctionType.Count)) {
                prestoType = NdpUtils.transOlkDataType(expression.dataType(), false);
            }
            omnidataTypes.add(prestoType);
            break;
        }
    }
    columnOrdersList.add(columnOrder++);
    switch(aggregateFunctionType) {
        case Sum:
        case Max:
        case Min:
            extractSumMaxMinAggregation(prestoType, aggregateFunctionName, aggregationMap);
            break;
        case Average:
            columnTypesList.add(new RowDecodeType());
            columnOrdersList.add(columnOrder++);
            extractAvgAggregation(prestoType, aggregateFunctionName, aggregationMap);
            break;
        case Count:
            columnTypesList.add(new LongDecodeType());
            extractCountAggregation(prestoType, aggregateFunctionName, aggregationMap);
            break;
    }
}
Also used : RowDecodeType(com.huawei.boostkit.omnidata.decode.type.RowDecodeType) RowDecodeType(com.huawei.boostkit.omnidata.decode.type.RowDecodeType) RowType(io.prestosql.spi.type.RowType) Type(io.prestosql.spi.type.Type) DecodeType(com.huawei.boostkit.omnidata.decode.type.DecodeType) BigintType(io.prestosql.spi.type.BigintType) LongDecodeType(com.huawei.boostkit.omnidata.decode.type.LongDecodeType) DoubleType(io.prestosql.spi.type.DoubleType) LongDecodeType(com.huawei.boostkit.omnidata.decode.type.LongDecodeType) ConstantExpression(io.prestosql.spi.relation.ConstantExpression) CallExpression(io.prestosql.spi.relation.CallExpression) Expression(org.apache.spark.sql.catalyst.expressions.Expression) NamedExpression(org.apache.spark.sql.catalyst.expressions.NamedExpression) InputReferenceExpression(io.prestosql.spi.relation.InputReferenceExpression) RowExpression(io.prestosql.spi.relation.RowExpression) Literal(org.apache.spark.sql.catalyst.expressions.Literal)

Aggregations

DecodeType (com.huawei.boostkit.omnidata.decode.type.DecodeType)1 LongDecodeType (com.huawei.boostkit.omnidata.decode.type.LongDecodeType)1 RowDecodeType (com.huawei.boostkit.omnidata.decode.type.RowDecodeType)1 CallExpression (io.prestosql.spi.relation.CallExpression)1 ConstantExpression (io.prestosql.spi.relation.ConstantExpression)1 InputReferenceExpression (io.prestosql.spi.relation.InputReferenceExpression)1 RowExpression (io.prestosql.spi.relation.RowExpression)1 BigintType (io.prestosql.spi.type.BigintType)1 DoubleType (io.prestosql.spi.type.DoubleType)1 RowType (io.prestosql.spi.type.RowType)1 Type (io.prestosql.spi.type.Type)1 Expression (org.apache.spark.sql.catalyst.expressions.Expression)1 Literal (org.apache.spark.sql.catalyst.expressions.Literal)1 NamedExpression (org.apache.spark.sql.catalyst.expressions.NamedExpression)1