public <T> T reflect(String functionName, Class<T> clazz) {
    Model model;
    if (UDF.class.isAssignableFrom(clazz)) {
      model = Model.TREE;
    } else if (SQLFunction.class.isAssignableFrom(clazz)) {
      model = Model.TABLE;
    } else {
      throw new UDFManagementException(
          "Unsupported UDF class type. Only UDF and SQLFunction are supported.");
    }
    UDFInformation information = udfTable.getUDFInformation(model, functionName);
    if (information == null) {
      String errorMessage =
          String.format(
              "Failed to reflect UDF instance, because UDF %s has not been registered.",
              functionName.toUpperCase());
      LOGGER.warn(errorMessage);
      throw new UDFException(errorMessage);
    }

    try {
      return clazz.cast(
          udfTable.getFunctionClass(model, functionName).getDeclaredConstructor().newInstance());
    } catch (InstantiationException
        | InvocationTargetException
        | NoSuchMethodException
        | IllegalAccessException e) {
      String errorMessage =
          String.format(
              "Failed to reflect UDF %s(%s) instance, because %s",
              functionName, information.getClassName(), e);
      LOGGER.warn(errorMessage, e);
      throw new UDFException(errorMessage);
    }
  }
Only call this method directly for registering new data node, otherwise you need to call
register().
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/udf/UDFManagementService.java