public static TSDataType getBuiltinAggregationDataType(
      String aggregationFunctionName, TSDataType dataType) {
    if (aggregationFunctionName == null) {
      throw new IllegalArgumentException("AggregateFunction Name must not be null");
    }
    verifyIsAggregationDataTypeMatched(aggregationFunctionName, dataType);

    switch (aggregationFunctionName.toLowerCase()) {
      case SqlConstant.MIN_TIME:
      case SqlConstant.MAX_TIME:
      case SqlConstant.COUNT:
      case SqlConstant.COUNT_TIME:
      case SqlConstant.COUNT_IF:
      case SqlConstant.TIME_DURATION:
        return TSDataType.INT64;
      case SqlConstant.MIN_VALUE:
      case SqlConstant.LAST_VALUE:
      case SqlConstant.FIRST_VALUE:
      case SqlConstant.MAX_VALUE:
      case SqlConstant.EXTREME:
      case SqlConstant.MODE:
      case SqlConstant.MAX_BY:
      case SqlConstant.MIN_BY:
        return dataType;
      case SqlConstant.AVG:
      case SqlConstant.SUM:
      case SqlConstant.STDDEV:
      case SqlConstant.STDDEV_POP:
      case SqlConstant.STDDEV_SAMP:
      case SqlConstant.VARIANCE:
      case SqlConstant.VAR_POP:
      case SqlConstant.VAR_SAMP:
        return TSDataType.DOUBLE;
      default:
        throw new IllegalArgumentException(
            "Invalid Aggregation function: " + aggregationFunctionName);
    }
  }
Get predicted DataType of the given value
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/TypeInferenceUtils.java