private static void verifyIsAggregationDataTypeMatched(String aggrFuncName, TSDataType dataType) {
    // input is NullOperand, needn't check
    if (dataType == null) {
      return;
    }
    switch (aggrFuncName.toLowerCase()) {
      case SqlConstant.MIN_VALUE:
      case SqlConstant.MAX_VALUE:
        if (dataType.isNumeric()
            || TSDataType.STRING.equals(dataType)
            || TSDataType.DATE.equals(dataType)
            || TSDataType.TIMESTAMP.equals(dataType)) {
          return;
        }
        throw new SemanticException(
            "Aggregate functions [MIN_VALUE, MAX_VALUE] only support data types [INT32, INT64, FLOAT, DOUBLE, STRING, DATE, TIMESTAMP]");
      case SqlConstant.AVG:
      case SqlConstant.SUM:
      case SqlConstant.EXTREME:
      case SqlConstant.STDDEV:
      case SqlConstant.STDDEV_POP:
      case SqlConstant.STDDEV_SAMP:
      case SqlConstant.VARIANCE:
      case SqlConstant.VAR_POP:
      case SqlConstant.VAR_SAMP:
        if (dataType.isNumeric()) {
          return;
        }
        throw new SemanticException(
            "Aggregate functions [AVG, SUM, EXTREME, STDDEV, STDDEV_POP, STDDEV_SAMP, VARIANCE, VAR_POP, VAR_SAMP] only support numeric data types [INT32, INT64, FLOAT, DOUBLE]");
      case SqlConstant.COUNT:
      case SqlConstant.COUNT_TIME:
      case SqlConstant.MIN_TIME:
      case SqlConstant.MAX_TIME:
      case SqlConstant.FIRST_VALUE:
      case SqlConstant.LAST_VALUE:
      case SqlConstant.TIME_DURATION:
      case SqlConstant.MODE:
      case SqlConstant.MAX_BY:
      case SqlConstant.MIN_BY:
        return;
      case SqlConstant.COUNT_IF:
        if (dataType != TSDataType.BOOLEAN) {
          throw new SemanticException(
              String.format(
                  "Input series of Aggregation function [%s] only supports data type [BOOLEAN]",
                  aggrFuncName));
        }
        return;
      default:
        throw new IllegalArgumentException("Invalid Aggregation function: " + aggrFuncName);
    }
  }
Get predicted DataType of the given value
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/TypeInferenceUtils.java