public static MessageType pruneColumnsFallback(MessageType fileSchema, Schema expectedSchema) {
    Set<Integer> selectedIds = Sets.newHashSet();

    for (Types.NestedField field : expectedSchema.columns()) {
      selectedIds.add(field.fieldId());
    }

    org.apache.parquet.schema.Types.MessageTypeBuilder builder =
        org.apache.parquet.schema.Types.buildMessage();

    int ordinal = 1;
    for (Type type : fileSchema.getFields()) {
      if (selectedIds.contains(ordinal)) {
        builder.addField(type.withId(ordinal));
      }
      ordinal += 1;
    }

    return builder.named(fileSchema.getName());
  }
Prunes columns from a Parquet file schema that was written without field ids.

<p>Files that were written without field ids are read assuming that schema evolution preserved
column order. Deleting columns was not allowed.

<p>The order of columns in the resulting Parquet schema matches the Parquet file.

@param fileSchema schema from a Parquet file that does not have field ids.
@param expectedSchema expected schema
@return a parquet schema pruned using the expected schema
amoro-format-mixed/amoro-mixed-hive/src/main/java/org/apache/iceberg/parquet/AdaptHiveParquetSchemaUtil.java