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);


    }
  }
Registers functions from the DataSketches library as builtin functions.

In an effort to show a more consistent
ql/src/java/org/apache/hadoop/hive/ql/exec/DataSketchesFunctions.java