public static Object convert(Type type, Object object) {
    if (object == null) {
      return null;
    }

    switch (type.typeId()) {
      case STRUCT:
        return convert(type.asStructType(), (HiveRow) object);

      case LIST:
        List<Object> convertedList = Lists.newArrayList();
        List<?> list = (List<?>) object;
        for (Object element : list) {
          convertedList.add(convert(type.asListType().elementType(), element));
        }
        return convertedList;

      case MAP:
        Map<Object, Object> convertedMap = Maps.newLinkedHashMap();
        Map<?, ?> map = (Map<?, ?>) object;
        for (Map.Entry<?, ?> entry : map.entrySet()) {
          convertedMap.put(
              convert(type.asMapType().keyType(), entry.getKey()),
              convert(type.asMapType().valueType(), entry.getValue()));
        }
        return convertedMap;

      case DATE:
        Date hiveDate = (Date) object;
        return LocalDate.of(hiveDate.getYear(), hiveDate.getMonth(), hiveDate.getDay());
      case TIMESTAMP:
        if (Types.TimestampType.withZone() == type) {
          throw new UnsupportedOperationException("Not supported with vectorization.");
        } else {
          // Hive's internal TS representation is in UTC
          return LocalDateTime.ofInstant(((Timestamp) object).toSqlTimestamp().toInstant(), ZoneId.of("UTC"));
        }
      case BINARY:
        return ByteBuffer.wrap((byte[]) object);
      case FIXED:
        return (byte[]) object;
      case DECIMAL:
        BigDecimal bigDecimal = ((HiveDecimal) object).bigDecimalValue();
        if (bigDecimal.longValue() == 0) {
          // For some reason for value=0 scale information is not preserved in Hive
          return bigDecimal.setScale(((Types.DecimalType) type).scale());
        }
        return bigDecimal;
      case INTEGER:
      case BOOLEAN:
      case LONG:
      case FLOAT:
      case DOUBLE:
      case STRING:
        return object;
      default:
        throw new UnsupportedOperationException("Not a supported type: " + type);
    }
  }
Converts from HiveRow to Iceberg's internal data representation format
aka from POJOs used by Hive to hold record data into those of Iceberg
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/vector/HiveValueConverter.java