Search in sources :

Example 1 with HiveMergeableAggregate

use of org.apache.hadoop.hive.ql.optimizer.calcite.functions.HiveMergeableAggregate in project hive by apache.

the class DataSketchesFunctions method buildCalciteFns.

private void buildCalciteFns() {
    for (SketchDescriptor sd : sketchClasses.values()) {
        registerAsHiveFunction(sd.fnMap.get(SKETCH_TO_ESTIMATE));
        registerAsHiveFunction(sd.fnMap.get(GET_QUANTILE));
        registerAsHiveFunction(sd.fnMap.get(GET_CDF));
        registerAsHiveFunction(sd.fnMap.get(GET_N));
        registerAsHiveFunction(sd.fnMap.get(GET_RANK));
        // Mergability is exposed to Calcite; which enables to use it during rollup.
        RelProtoDataType sketchType = RelDataTypeImpl.proto(SqlTypeName.BINARY, true);
        SketchFunctionDescriptor sketchSFD = sd.fnMap.get(DATA_TO_SKETCH);
        SketchFunctionDescriptor unionSFD = sd.fnMap.get(UNION_SKETCH);
        if (sketchSFD == null || unionSFD == null) {
            continue;
        }
        HiveMergeableAggregate unionFn = new HiveMergeableAggregate(unionSFD.name, SqlKind.OTHER_FUNCTION, ReturnTypes.explicit(sketchType), InferTypes.ANY_NULLABLE, OperandTypes.family(), null);
        HiveMergeableAggregate sketchFn = new HiveMergeableAggregate(sketchSFD.name, SqlKind.OTHER_FUNCTION, ReturnTypes.explicit(sketchType), InferTypes.ANY_NULLABLE, OperandTypes.family(), unionFn);
        unionSFD.setCalciteFunction(unionFn);
        sketchSFD.setCalciteFunction(sketchFn);
    }
}
Also used : RelProtoDataType(org.apache.calcite.rel.type.RelProtoDataType) HiveMergeableAggregate(org.apache.hadoop.hive.ql.optimizer.calcite.functions.HiveMergeableAggregate)

Aggregations

RelProtoDataType (org.apache.calcite.rel.type.RelProtoDataType)1 HiveMergeableAggregate (org.apache.hadoop.hive.ql.optimizer.calcite.functions.HiveMergeableAggregate)1