@SuppressWarnings("unchecked")
  private static <T> void updateMax(
      Map<Integer, Literal<?>> upperBounds,
      int id,
      Type type,
      Literal<T> max,
      MetricsModes.MetricsMode metricsMode) {
    Literal<T> currentMax = (Literal<T>) upperBounds.get(id);
    if (currentMax == null || max.comparator().compare(max.value(), currentMax.value()) > 0) {
      if (metricsMode == MetricsModes.Full.get()) {
        upperBounds.put(id, max);
      } else {
        MetricsModes.Truncate truncateMode = (MetricsModes.Truncate) metricsMode;
        int truncateLength = truncateMode.length();
        switch (type.typeId()) {
          case STRING:
            Literal<CharSequence> truncatedMaxString =
                UnicodeUtil.truncateStringMax((Literal<CharSequence>) max, truncateLength);
            if (truncatedMaxString != null) {
              upperBounds.put(id, truncatedMaxString);
            }
            break;
          case FIXED:
          case BINARY:
            Literal<ByteBuffer> truncatedMaxBinary =
                BinaryUtil.truncateBinaryMax((Literal<ByteBuffer>) max, truncateLength);
            if (truncatedMaxBinary != null) {
              upperBounds.put(id, truncatedMaxBinary);
            }
            break;
          default:
            upperBounds.put(id, max);
        }
      }
    }
  }
Copy from {@link ParquetUtil} to resolve int96 in metric.
amoro-format-mixed/amoro-mixed-hive/src/main/java/org/apache/iceberg/parquet/AdaptHiveParquetUtil.java