You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "RussellSpitzer (via GitHub)" <gi...@apache.org> on 2026/03/15 02:21:40 UTC

[PR] Core, Parquet: Allow for Writing Parquet/Avro Manifests in V4 [iceberg]

RussellSpitzer opened a new pull request, #15634:
URL: https://github.com/apache/iceberg/pull/15634

   Extends V4 Manifest writer to allow it to write manifests in either Parquet or Avro based on the file extension. A default is also added to do Parquet Manifests in the SDK when the Version is 4. This could be parameterized later but that will require parameterizing the test suites so I decided on a single format (parquet) for now.
   
   There are a few other required changes here outside of testing
   
   1. Handling of splitOffsets in Parquet needs to be changed since BaseFile returns an immutable view which Parquet was attempting to re-use by clearing.
   
   2. Unpartitioned Tables need special care since parquet cannot store empty structs in the schema. This means reading from parquet manifests means skipping the parquet field and then changing read offsets if the partition is not defined. The read code is shared between all versions at this time so this change effects older avro readers as well.
   
   3. Some of the tests code for TestReplacePartitions assumed that you could validate against a slightly different vesrion of the table. This is a problem if the table you make is partitioned and the validation table is unpartitioned. It use to work ... accidently I think because we would make unpartitioned operations committed to a partitioned table.
   
   --- Some Benchmarks
   *Note this is all done with Full reads, while we expect writes to be slower, reads should be faster when we actually do column specific projection. Since in this code the avro and parquet read paths are both doing full scans we don't expect them to be materially different.*
   
   <img width="1561" height="1086" alt="image" src="https://github.com/user-attachments/assets/3ef17093-3745-4417-8683-bcd81176f82a" />
   
   I also deleted the old Manifest benchmarks which were specific to V1, and V1/V2 respectively and replaced them with a new benchmark which can be used on any version
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, Parquet: Allow for Writing Parquet/Avro Manifests in V4 [iceberg]

Posted by "RussellSpitzer (via GitHub)" <gi...@apache.org>.
RussellSpitzer commented on code in PR #15634:
URL: https://github.com/apache/iceberg/pull/15634#discussion_r2996156957


##########
core/src/main/java/org/apache/iceberg/V4Metadata.java:
##########
@@ -278,28 +279,35 @@ static Schema wrapFileSchema(Types.StructType fileSchema) {
   }
 
   static Types.StructType fileType(Types.StructType partitionType) {
-    return Types.StructType.of(
-        DataFile.CONTENT.asRequired(),
-        DataFile.FILE_PATH,
-        DataFile.FILE_FORMAT,
-        required(
-            DataFile.PARTITION_ID, DataFile.PARTITION_NAME, partitionType, DataFile.PARTITION_DOC),
-        DataFile.RECORD_COUNT,
-        DataFile.FILE_SIZE,
-        DataFile.COLUMN_SIZES,
-        DataFile.VALUE_COUNTS,
-        DataFile.NULL_VALUE_COUNTS,
-        DataFile.NAN_VALUE_COUNTS,
-        DataFile.LOWER_BOUNDS,
-        DataFile.UPPER_BOUNDS,
-        DataFile.KEY_METADATA,
-        DataFile.SPLIT_OFFSETS,
-        DataFile.EQUALITY_IDS,
-        DataFile.SORT_ORDER_ID,
-        DataFile.FIRST_ROW_ID,
-        DataFile.REFERENCED_DATA_FILE,
-        DataFile.CONTENT_OFFSET,
-        DataFile.CONTENT_SIZE);
+    List<Types.NestedField> fields = Lists.newArrayList();
+    fields.add(DataFile.CONTENT.asRequired());
+    fields.add(DataFile.FILE_PATH);
+    fields.add(DataFile.FILE_FORMAT);
+    if (!partitionType.fields().isEmpty()) {

Review Comment:
   We need to omit this field for unpartitioned tables if we are using parquet because parquet doesn't support the empty struct



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, Parquet: Allow for Writing Parquet/Avro Manifests in V4 [iceberg]

Posted by "RussellSpitzer (via GitHub)" <gi...@apache.org>.
RussellSpitzer commented on code in PR #15634:
URL: https://github.com/apache/iceberg/pull/15634#discussion_r3010754899


##########
core/src/main/java/org/apache/iceberg/ManifestWriter.java:
##########
@@ -65,7 +67,8 @@ private ManifestWriter(
       Long snapshotId,
       Long firstRowId,
       Map<String, String> writerProperties) {
-    this.file = file.encryptingOutputFile();
+    this.format = FileFormat.fromFileName(file.encryptingOutputFile().location());

Review Comment:
   @rdblue and i were debating whether or not we want to let engines still choose whether they want to use Avro or not. So for the moment I'm leaving it open. We can always close it down later when we actually change the spec. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, Parquet: Allow for Writing Parquet/Avro Manifests in V4 [iceberg]

Posted by "RussellSpitzer (via GitHub)" <gi...@apache.org>.
RussellSpitzer commented on code in PR #15634:
URL: https://github.com/apache/iceberg/pull/15634#discussion_r3112564400


##########
parquet/src/main/java/org/apache/iceberg/parquet/ParquetValueReaders.java:
##########
@@ -847,7 +849,8 @@ protected List<E> newListData(List<E> reuse) {
       }
 
       if (reuse != null) {
-        this.lastList = reuse;
+        // reuse containers may come from a different reader (e.g. Avro) with incompatible types
+        this.lastList = reuse instanceof ArrayList ? reuse : null;

Review Comment:
   I'll switch it to a disallow immutable, instaed of allow mutable



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, Parquet: Allow for Writing Parquet/Avro Manifests in V4 [iceberg]

Posted by "nastra (via GitHub)" <gi...@apache.org>.
nastra commented on PR #15634:
URL: https://github.com/apache/iceberg/pull/15634#issuecomment-4236019024

   > @RussellSpitzer why would we have performance difference btw V3 Avro and V4 Avro? new column stats storage?
   
   There is currently no code that would store the new v4 column stats, so the diff must be coming from something else


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, Parquet: Allow for Writing Parquet/Avro Manifests in V4 [iceberg]

Posted by "RussellSpitzer (via GitHub)" <gi...@apache.org>.
RussellSpitzer commented on PR #15634:
URL: https://github.com/apache/iceberg/pull/15634#issuecomment-4520175783

   oh and @anoopj :)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, Parquet: Allow for Writing Parquet/Avro Manifests in V4 [iceberg]

Posted by "RussellSpitzer (via GitHub)" <gi...@apache.org>.
RussellSpitzer commented on PR #15634:
URL: https://github.com/apache/iceberg/pull/15634#issuecomment-4136274362

   @anoopj Ok! Everything is good for review now. Please if you have a moment take a look


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, Parquet: Allow for Writing Parquet/Avro Manifests in V4 [iceberg]

Posted by "stevenzwu (via GitHub)" <gi...@apache.org>.
stevenzwu commented on PR #15634:
URL: https://github.com/apache/iceberg/pull/15634#issuecomment-4181921335

   @RussellSpitzer why would we have performance difference btw V3 Avro and V4 Avro? new column stats storage?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, Parquet: Allow for Writing Parquet/Avro Manifests in V4 [iceberg]

Posted by "stevenzwu (via GitHub)" <gi...@apache.org>.
stevenzwu commented on code in PR #15634:
URL: https://github.com/apache/iceberg/pull/15634#discussion_r3031497666


##########
core/src/test/java/org/apache/iceberg/TestBase.java:
##########
@@ -453,6 +464,10 @@ void validateSnapshot(Snapshot old, Snapshot snap, long sequenceNumber, DataFile
     validateSnapshot(old, snap, (Long) sequenceNumber, newFiles);
   }
 
+  void validateSnapshot(Table validationTable, Snapshot old, Snapshot snap, DataFile... newFiles) {

Review Comment:
   this overload already exists in line 459



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, Parquet: Allow for Writing Parquet/Avro Manifests in V4 [iceberg]

Posted by "stevenzwu (via GitHub)" <gi...@apache.org>.
stevenzwu commented on code in PR #15634:
URL: https://github.com/apache/iceberg/pull/15634#discussion_r3103637597


##########
core/src/main/java/org/apache/iceberg/ManifestWriter.java:
##########
@@ -65,7 +67,8 @@ private ManifestWriter(
       Long snapshotId,
       Long firstRowId,
       Map<String, String> writerProperties) {
-    this.file = file.encryptingOutputFile();
+    this.format = FileFormat.fromFileName(file.encryptingOutputFile().location());

Review Comment:
   should the file format be passed in as an arg?



##########
core/src/main/java/org/apache/iceberg/V4Metadata.java:
##########
@@ -278,28 +279,35 @@ static Schema wrapFileSchema(Types.StructType fileSchema) {
   }
 
   static Types.StructType fileType(Types.StructType partitionType) {
-    return Types.StructType.of(
-        DataFile.CONTENT.asRequired(),
-        DataFile.FILE_PATH,
-        DataFile.FILE_FORMAT,
-        required(
-            DataFile.PARTITION_ID, DataFile.PARTITION_NAME, partitionType, DataFile.PARTITION_DOC),
-        DataFile.RECORD_COUNT,
-        DataFile.FILE_SIZE,
-        DataFile.COLUMN_SIZES,
-        DataFile.VALUE_COUNTS,
-        DataFile.NULL_VALUE_COUNTS,
-        DataFile.NAN_VALUE_COUNTS,
-        DataFile.LOWER_BOUNDS,
-        DataFile.UPPER_BOUNDS,
-        DataFile.KEY_METADATA,
-        DataFile.SPLIT_OFFSETS,
-        DataFile.EQUALITY_IDS,
-        DataFile.SORT_ORDER_ID,
-        DataFile.FIRST_ROW_ID,
-        DataFile.REFERENCED_DATA_FILE,
-        DataFile.CONTENT_OFFSET,
-        DataFile.CONTENT_SIZE);
+    List<Types.NestedField> fields = Lists.newArrayList();
+    fields.add(DataFile.CONTENT.asRequired());
+    fields.add(DataFile.FILE_PATH);
+    fields.add(DataFile.FILE_FORMAT);
+    if (!partitionType.fields().isEmpty()) {

Review Comment:
   can we make this field optional and write null instead? I am asking because the `adjust` position in the V4Metadata irks me a bit.



##########
core/src/main/java/org/apache/iceberg/BaseFile.java:
##########
@@ -329,7 +330,9 @@ protected <T> void internalSet(int pos, T value) {
         this.partitionSpecId = (value != null) ? (Integer) value : -1;
         return;
       case 4:
-        this.partitionData = (PartitionData) value;
+        if (value != null) {

Review Comment:
   nit: `value != null ? (PartitionData) value : null`



##########
core/src/main/java/org/apache/iceberg/ManifestWriter.java:
##########
@@ -240,6 +248,18 @@ public ManifestFile toManifestFile() {
         firstRowId);
   }
 
+  private ByteBuffer keyMetadataBuffer() {
+    if (keyMetadata instanceof NativeEncryptionKeyMetadata nativeKeyMetadata

Review Comment:
   The `NativeEncryptionKeyMetadata` puts me off a bit maybe due to the name `Native`. I thought only Parquet file format has native encryption. Avro files use the generic AES GCM encryption.
   
   the logic seems the same as the old code. So this is good.



##########
core/src/main/java/org/apache/iceberg/ManifestWriter.java:
##########
@@ -82,6 +85,20 @@ private ManifestWriter(
   protected abstract FileAppender<ManifestEntry<F>> newAppender(
       PartitionSpec spec, OutputFile outputFile);
 
+  private OutputFile outputFile(EncryptedOutputFile encryptedFile) {
+    // Casting to NativeEncryptionOutputFile actually makes the file rely on native encryption
+    // rather than whole-file encryption.
+    if (format == FileFormat.PARQUET
+        && encryptedFile instanceof NativeEncryptionOutputFile nativeFile) {
+      return nativeFile;
+    }
+    return encryptedFile.encryptingOutputFile();

Review Comment:
   nit: missing empty line after control block in a few places



##########
core/src/jmh/java/org/apache/iceberg/ManifestBenchmarkUtil.java:
##########
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iceberg;
+
+import java.nio.ByteBuffer;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Random;
+import org.apache.commons.io.FileUtils;
+import org.apache.iceberg.relocated.com.google.common.collect.Lists;
+import org.apache.iceberg.relocated.com.google.common.collect.Maps;
+import org.apache.iceberg.types.Types;
+
+/**
+ * Shared constants and stateless helpers for {@link ManifestBenchmark} and {@link
+ * ManifestCompressionBenchmark}.
+ */
+final class ManifestBenchmarkUtil {
+
+  static final Schema SCHEMA =
+      new Schema(
+          Types.NestedField.required(1, "id", Types.IntegerType.get()),
+          Types.NestedField.required(2, "data", Types.StringType.get()),
+          Types.NestedField.required(3, "customer", Types.StringType.get()));
+
+  static final PartitionSpec SPEC =
+      PartitionSpec.builderFor(SCHEMA).identity("id").identity("data").identity("customer").build();
+
+  private ManifestBenchmarkUtil() {}
+
+  /**
+   * Returns the number of manifest entries for the given column count. The result is {@code
+   * entryBase / cols}.
+   *
+   * <p>The linear ratio was determined empirically by writing manifests at various column counts
+   * and measuring the resulting file sizes. An {@code entryBase} of 300,000 produces ~8 MB
+   * manifests (matching the default {@code commit.manifest.target-size-bytes}); 15,000 produces
+   * ~400 KB.
+   */
+  static int entriesForColumnCount(int entryBase, int cols) {
+    return entryBase / cols;
+  }
+
+  static List<DataFile> generateDataFiles(PartitionSpec spec, int numEntries, int numCols) {
+    Random random = new Random(42);
+    List<DataFile> files = Lists.newArrayListWithCapacity(numEntries);
+    for (int i = 0; i < numEntries; i++) {
+      DataFiles.Builder builder =
+          DataFiles.builder(spec)
+              .withFormat(FileFormat.PARQUET)
+              .withPath(String.format(Locale.ROOT, "/path/to/data-%d.parquet", i))
+              .withFileSizeInBytes(1024 + i)
+              .withRecordCount(1000 + i)
+              .withMetrics(randomMetrics(random, numCols));
+
+      if (!spec.isUnpartitioned()) {

Review Comment:
   nit: `isPartitioned`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, Parquet: Allow for Writing Parquet/Avro Manifests in V4 [iceberg]

Posted by "RussellSpitzer (via GitHub)" <gi...@apache.org>.
RussellSpitzer commented on code in PR #15634:
URL: https://github.com/apache/iceberg/pull/15634#discussion_r2996102092


##########
core/src/main/java/org/apache/iceberg/ManifestReader.java:
##########
@@ -154,6 +154,12 @@ private <T extends ContentFile<T>> PartitionSpec readPartitionSpec(InputFile inp
   }
 
   private static <T extends ContentFile<T>> Map<String, String> readMetadata(InputFile inputFile) {
+    FileFormat manifestFormat = FileFormat.fromFileName(inputFile.location());
+    Preconditions.checkArgument(
+        manifestFormat == FileFormat.AVRO,
+        "Reading manifest metadata is only supported for Avro manifests: %s",

Review Comment:
   Now that I fixed all the tests, there is no code inside the Iceberg project that relies on this code path.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, Parquet: Allow for Writing Parquet/Avro Manifests in V4 [iceberg]

Posted by "anoopj (via GitHub)" <gi...@apache.org>.
anoopj commented on code in PR #15634:
URL: https://github.com/apache/iceberg/pull/15634#discussion_r3003733441


##########
core/src/main/java/org/apache/iceberg/ManifestReader.java:
##########
@@ -281,8 +294,22 @@ private CloseableIterable<ManifestEntry<F>> open(Schema projection) {
     Preconditions.checkArgument(
         format != null, "Unable to determine format of manifest: %s", file.location());
 
+    boolean unpartitioned = spec.rawPartitionType().fields().isEmpty();
+
+    // V4+ manifests omit the partition field when unpartitioned (Parquet cannot represent
+    // empty structs, and the field is meaningless regardless of format). Mark it optional so
+    // the reader returns null for the missing field instead of throwing. The field must stay
+    // in the projection to preserve positional access for callers like StructProjection.
+    // For older versions where the empty struct is present, making it optional is harmless.
     List<Types.NestedField> fields = Lists.newArrayList();
-    fields.addAll(projection.asStruct().fields());
+    for (Types.NestedField field : projection.asStruct().fields()) {

Review Comment:
   As mentioned above, we can clean this up after v4 data structures get added, since we are folding partition into content_stats.



##########
core/src/main/java/org/apache/iceberg/V4Metadata.java:
##########
@@ -278,28 +279,35 @@ static Schema wrapFileSchema(Types.StructType fileSchema) {
   }
 
   static Types.StructType fileType(Types.StructType partitionType) {
-    return Types.StructType.of(
-        DataFile.CONTENT.asRequired(),
-        DataFile.FILE_PATH,
-        DataFile.FILE_FORMAT,
-        required(
-            DataFile.PARTITION_ID, DataFile.PARTITION_NAME, partitionType, DataFile.PARTITION_DOC),
-        DataFile.RECORD_COUNT,
-        DataFile.FILE_SIZE,
-        DataFile.COLUMN_SIZES,
-        DataFile.VALUE_COUNTS,
-        DataFile.NULL_VALUE_COUNTS,
-        DataFile.NAN_VALUE_COUNTS,
-        DataFile.LOWER_BOUNDS,
-        DataFile.UPPER_BOUNDS,
-        DataFile.KEY_METADATA,
-        DataFile.SPLIT_OFFSETS,
-        DataFile.EQUALITY_IDS,
-        DataFile.SORT_ORDER_ID,
-        DataFile.FIRST_ROW_ID,
-        DataFile.REFERENCED_DATA_FILE,
-        DataFile.CONTENT_OFFSET,
-        DataFile.CONTENT_SIZE);
+    List<Types.NestedField> fields = Lists.newArrayList();
+    fields.add(DataFile.CONTENT.asRequired());
+    fields.add(DataFile.FILE_PATH);
+    fields.add(DataFile.FILE_FORMAT);
+    if (!partitionType.fields().isEmpty()) {

Review Comment:
   In v4, we are folding partition into `content_stats`, so this problem goes away when we merge the v4 `TrackedFile` code in.



##########
core/src/main/java/org/apache/iceberg/ManifestWriter.java:
##########
@@ -65,7 +67,8 @@ private ManifestWriter(
       Long snapshotId,
       Long firstRowId,
       Map<String, String> writerProperties) {
-    this.file = file.encryptingOutputFile();
+    this.format = FileFormat.fromFileName(file.encryptingOutputFile().location());

Review Comment:
   V4 will always have Parquet right? so the decision to use the right extension is made somewhere upstream?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, Parquet: Allow for Writing Parquet/Avro Manifests in V4 [iceberg]

Posted by "RussellSpitzer (via GitHub)" <gi...@apache.org>.
RussellSpitzer commented on code in PR #15634:
URL: https://github.com/apache/iceberg/pull/15634#discussion_r3112615075


##########
core/src/main/java/org/apache/iceberg/BaseFile.java:
##########
@@ -581,9 +584,33 @@ private static <K, V> Map<K, V> copyMap(Map<K, V> map, Set<K> keys) {
 
   private static Map<Integer, ByteBuffer> copyByteBufferMap(
       Map<Integer, ByteBuffer> map, Set<Integer> keys) {
-    return SerializableByteBufferMap.wrap(copyMap(map, keys));
+    if (map == null) {
+      return null;
+    }
+
+    // This is required as long as we have Map<Integer, ByteBuffer> in the API since Parquet is
+    // re-using buffers.
+    Map<Integer, ByteBuffer> deepCopy = Maps.newHashMapWithExpectedSize(map.size());

Review Comment:
   Sgtm



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, Parquet: Allow for Writing Parquet/Avro Manifests in V4 [iceberg]

Posted by "RussellSpitzer (via GitHub)" <gi...@apache.org>.
RussellSpitzer commented on PR #15634:
URL: https://github.com/apache/iceberg/pull/15634#issuecomment-4156163139

   Force pushed after rebasing on the test replace partitions fix #15798


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, Parquet: Allow for Writing Parquet/Avro Manifests in V4 [iceberg]

Posted by "RussellSpitzer (via GitHub)" <gi...@apache.org>.
RussellSpitzer commented on code in PR #15634:
URL: https://github.com/apache/iceberg/pull/15634#discussion_r3032521888


##########
core/src/test/java/org/apache/iceberg/TestBase.java:
##########
@@ -472,6 +487,16 @@ Snapshot apply(SnapshotUpdate<?> snapshotUpdate, String branch) {
   }
 
   void validateSnapshot(Snapshot old, Snapshot snap, Long sequenceNumber, DataFile... newFiles) {
+    validateSnapshot(table, old, snap, sequenceNumber, newFiles);
+  }
+
+  @SuppressWarnings("checkstyle:HiddenField")
+  void validateSnapshot(

Review Comment:
   Fixed in  #15798 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, Parquet: Allow for Writing Parquet/Avro Manifests in V4 [iceberg]

Posted by "RussellSpitzer (via GitHub)" <gi...@apache.org>.
RussellSpitzer commented on code in PR #15634:
URL: https://github.com/apache/iceberg/pull/15634#discussion_r3032506210


##########
core/src/test/java/org/apache/iceberg/TestBase.java:
##########
@@ -453,6 +464,10 @@ void validateSnapshot(Snapshot old, Snapshot snap, long sequenceNumber, DataFile
     validateSnapshot(old, snap, (Long) sequenceNumber, newFiles);
   }
 
+  void validateSnapshot(Table validationTable, Snapshot old, Snapshot snap, DataFile... newFiles) {

Review Comment:
   Slightly different, That one doesn't take sequence number



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, Parquet: Allow for Writing Parquet/Avro Manifests in V4 [iceberg]

Posted by "RussellSpitzer (via GitHub)" <gi...@apache.org>.
RussellSpitzer commented on PR #15634:
URL: https://github.com/apache/iceberg/pull/15634#issuecomment-4062012663

   @anoopj I hear your PR #15049  will make this a lot cleaner, so I will review that on Monday :)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, Parquet: Allow for Writing Parquet/Avro Manifests in V4 [iceberg]

Posted by "RussellSpitzer (via GitHub)" <gi...@apache.org>.
RussellSpitzer commented on code in PR #15634:
URL: https://github.com/apache/iceberg/pull/15634#discussion_r2996265194


##########
core/src/test/java/org/apache/iceberg/TestReplacePartitions.java:
##########
@@ -188,14 +188,17 @@ public void testReplaceWithUnpartitionedTable() throws IOException {
 
     assertThat(TestTables.metadataVersion("unpartitioned")).isEqualTo(0);
 
-    commit(table, unpartitioned.newAppend().appendFile(FILE_A), branch);
+    commit(unpartitioned, unpartitioned.newAppend().appendFile(FILE_A), branch);

Review Comment:
   Here are tests that were being tested against the wrong table previously. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, Parquet: Allow for Writing Parquet/Avro Manifests in V4 [iceberg]

Posted by "RussellSpitzer (via GitHub)" <gi...@apache.org>.
RussellSpitzer commented on code in PR #15634:
URL: https://github.com/apache/iceberg/pull/15634#discussion_r2996097359


##########
core/src/main/java/org/apache/iceberg/ManifestReader.java:
##########
@@ -281,8 +294,22 @@ private CloseableIterable<ManifestEntry<F>> open(Schema projection) {
     Preconditions.checkArgument(
         format != null, "Unable to determine format of manifest: %s", file.location());
 
+    boolean unpartitioned = spec.rawPartitionType().fields().isEmpty();
+
+    // V4+ manifests omit the partition field when unpartitioned (Parquet cannot represent
+    // empty structs, and the field is meaningless regardless of format). Mark it optional so
+    // the reader returns null for the missing field instead of throwing. The field must stay
+    // in the projection to preserve positional access for callers like StructProjection.
+    // For older versions where the empty struct is present, making it optional is harmless.
     List<Types.NestedField> fields = Lists.newArrayList();
-    fields.addAll(projection.asStruct().fields());
+    for (Types.NestedField field : projection.asStruct().fields()) {

Review Comment:
   As the large comment above says, this is where we are handling the fact that Parquet doesn't like empty structs. We just inject an "empty - optional" parquet field so we can just get nulls in that slot. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, Parquet: Allow for Writing Parquet/Avro Manifests in V4 [iceberg]

Posted by "RussellSpitzer (via GitHub)" <gi...@apache.org>.
RussellSpitzer commented on code in PR #15634:
URL: https://github.com/apache/iceberg/pull/15634#discussion_r2996087754


##########
core/src/jmh/java/org/apache/iceberg/ManifestBenchmark.java:
##########
@@ -18,23 +18,15 @@
  */
 package org.apache.iceberg;

Review Comment:
   I split off the Compression Benchmark into it's own file 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, Parquet: Allow for Writing Parquet/Avro Manifests in V4 [iceberg]

Posted by "RussellSpitzer (via GitHub)" <gi...@apache.org>.
RussellSpitzer commented on code in PR #15634:
URL: https://github.com/apache/iceberg/pull/15634#discussion_r3283983347


##########
core/src/main/java/org/apache/iceberg/V4Metadata.java:
##########
@@ -278,28 +279,35 @@ static Schema wrapFileSchema(Types.StructType fileSchema) {
   }
 
   static Types.StructType fileType(Types.StructType partitionType) {
-    return Types.StructType.of(
-        DataFile.CONTENT.asRequired(),
-        DataFile.FILE_PATH,
-        DataFile.FILE_FORMAT,
-        required(
-            DataFile.PARTITION_ID, DataFile.PARTITION_NAME, partitionType, DataFile.PARTITION_DOC),
-        DataFile.RECORD_COUNT,
-        DataFile.FILE_SIZE,
-        DataFile.COLUMN_SIZES,
-        DataFile.VALUE_COUNTS,
-        DataFile.NULL_VALUE_COUNTS,
-        DataFile.NAN_VALUE_COUNTS,
-        DataFile.LOWER_BOUNDS,
-        DataFile.UPPER_BOUNDS,
-        DataFile.KEY_METADATA,
-        DataFile.SPLIT_OFFSETS,
-        DataFile.EQUALITY_IDS,
-        DataFile.SORT_ORDER_ID,
-        DataFile.FIRST_ROW_ID,
-        DataFile.REFERENCED_DATA_FILE,
-        DataFile.CONTENT_OFFSET,
-        DataFile.CONTENT_SIZE);
+    List<Types.NestedField> fields = Lists.newArrayList();
+    fields.add(DataFile.CONTENT.asRequired());
+    fields.add(DataFile.FILE_PATH);
+    fields.add(DataFile.FILE_FORMAT);
+    if (!partitionType.fields().isEmpty()) {

Review Comment:
   Not really, It basically would go back to our initial problem. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, Parquet: Allow for Writing Parquet/Avro Manifests in V4 [iceberg]

Posted by "RussellSpitzer (via GitHub)" <gi...@apache.org>.
RussellSpitzer commented on code in PR #15634:
URL: https://github.com/apache/iceberg/pull/15634#discussion_r3010758862


##########
core/src/main/java/org/apache/iceberg/ManifestReader.java:
##########
@@ -281,8 +294,22 @@ private CloseableIterable<ManifestEntry<F>> open(Schema projection) {
     Preconditions.checkArgument(
         format != null, "Unable to determine format of manifest: %s", file.location());
 
+    boolean unpartitioned = spec.rawPartitionType().fields().isEmpty();
+
+    // V4+ manifests omit the partition field when unpartitioned (Parquet cannot represent
+    // empty structs, and the field is meaningless regardless of format). Mark it optional so
+    // the reader returns null for the missing field instead of throwing. The field must stay
+    // in the projection to preserve positional access for callers like StructProjection.
+    // For older versions where the empty struct is present, making it optional is harmless.
     List<Types.NestedField> fields = Lists.newArrayList();
-    fields.addAll(projection.asStruct().fields());
+    for (Types.NestedField field : projection.asStruct().fields()) {

Review Comment:
   Yes i'm very excited for that. Not sure if you want to get that in first then this, or vice versa. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, Parquet: Allow for Writing Parquet/Avro Manifests in V4 [iceberg]

Posted by "RussellSpitzer (via GitHub)" <gi...@apache.org>.
RussellSpitzer commented on code in PR #15634:
URL: https://github.com/apache/iceberg/pull/15634#discussion_r2996258635


##########
core/src/test/java/org/apache/iceberg/TestBase.java:
##########
@@ -472,6 +487,16 @@ Snapshot apply(SnapshotUpdate<?> snapshotUpdate, String branch) {
   }
 
   void validateSnapshot(Snapshot old, Snapshot snap, Long sequenceNumber, DataFile... newFiles) {
+    validateSnapshot(table, old, snap, sequenceNumber, newFiles);
+  }
+
+  @SuppressWarnings("checkstyle:HiddenField")
+  void validateSnapshot(

Review Comment:
   We had to do some changes here but it wasn't actually related to V4 but was exposed by the "missing partition spec" field.
   
   Basically we had some tests like 
   TestReplacePartitions 
   
   That would validate against the wrong table but it happened to work because AVRO didn't care if the "SPEC" information was incorrect, it would just go ahead and read the manifests. With Parquet there is now a missing field if the table is unpartitioned so you get an actual read error when you validate with the wrong table.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, Parquet: Allow for Writing Parquet/Avro Manifests in V4 [iceberg]

Posted by "RussellSpitzer (via GitHub)" <gi...@apache.org>.
RussellSpitzer commented on code in PR #15634:
URL: https://github.com/apache/iceberg/pull/15634#discussion_r3032515397


##########
core/src/test/java/org/apache/iceberg/TestBase.java:
##########
@@ -453,6 +464,10 @@ void validateSnapshot(Snapshot old, Snapshot snap, long sequenceNumber, DataFile
     validateSnapshot(old, snap, (Long) sequenceNumber, newFiles);
   }
 
+  void validateSnapshot(Table validationTable, Snapshot old, Snapshot snap, DataFile... newFiles) {

Review Comment:
   nevermind, this is from the rebase! Yeah i'll pull this out. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, Parquet: Allow for Writing Parquet/Avro Manifests in V4 [iceberg]

Posted by "RussellSpitzer (via GitHub)" <gi...@apache.org>.
RussellSpitzer commented on code in PR #15634:
URL: https://github.com/apache/iceberg/pull/15634#discussion_r3113367268


##########
parquet/src/main/java/org/apache/iceberg/parquet/ParquetValueReaders.java:
##########
@@ -847,7 +849,8 @@ protected List<E> newListData(List<E> reuse) {
       }
 
       if (reuse != null) {
-        this.lastList = reuse;
+        // reuse containers may come from a different reader (e.g. Avro) with incompatible types
+        this.lastList = reuse instanceof ArrayList ? reuse : null;

Review Comment:
   Ok turns out this is really trick to make a "dissallow" list since the JDK immutables are package private so we can't actually do instanceOf Checks to determine if a list is immutable. We could do "forName" checks" but that's kind of gross
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, Parquet: Allow for Writing Parquet/Avro Manifests in V4 [iceberg]

Posted by "RussellSpitzer (via GitHub)" <gi...@apache.org>.
RussellSpitzer commented on PR #15634:
URL: https://github.com/apache/iceberg/pull/15634#issuecomment-4068759391

   I have missed some deprecations and test rewrites, going to split those off to another branch to resolve first to not confuse this pr.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, Parquet: Allow for Writing Parquet/Avro Manifests in V4 [iceberg]

Posted by "RussellSpitzer (via GitHub)" <gi...@apache.org>.
RussellSpitzer commented on PR #15634:
URL: https://github.com/apache/iceberg/pull/15634#issuecomment-4520174583

   @stevenzwu + @nastra Now that 1.11 is out I feel comfortable merging this for our ongoing V4 work. Are you both in alignment? Can I merge?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, Parquet: Allow for Writing Parquet/Avro Manifests in V4 [iceberg]

Posted by "RussellSpitzer (via GitHub)" <gi...@apache.org>.
RussellSpitzer commented on PR #15634:
URL: https://github.com/apache/iceberg/pull/15634#issuecomment-4068105498

   <img width="1413" height="1047" alt="image" src="https://github.com/user-attachments/assets/91cdbadf-0c1a-481f-a13b-1864c13dbd43" />
   Updated with the new benchmark code


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, Parquet: Allow for Writing Parquet/Avro Manifests in V4 [iceberg]

Posted by "RussellSpitzer (via GitHub)" <gi...@apache.org>.
RussellSpitzer commented on code in PR #15634:
URL: https://github.com/apache/iceberg/pull/15634#discussion_r2996112045


##########
core/src/main/java/org/apache/iceberg/ManifestReader.java:
##########
@@ -291,14 +318,16 @@ private CloseableIterable<ManifestEntry<F>> open(Schema projection) {
     }
     fields.add(MetadataColumns.ROW_POSITION);
 
-    CloseableIterable<ManifestEntry<F>> reader =

Review Comment:
   Looking back we don't need to change this at all now, i'll clean that up



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, Parquet: Allow for Writing Parquet/Avro Manifests in V4 [iceberg]

Posted by "RussellSpitzer (via GitHub)" <gi...@apache.org>.
RussellSpitzer commented on code in PR #15634:
URL: https://github.com/apache/iceberg/pull/15634#discussion_r2996156957


##########
core/src/main/java/org/apache/iceberg/V4Metadata.java:
##########
@@ -278,28 +279,35 @@ static Schema wrapFileSchema(Types.StructType fileSchema) {
   }
 
   static Types.StructType fileType(Types.StructType partitionType) {
-    return Types.StructType.of(
-        DataFile.CONTENT.asRequired(),
-        DataFile.FILE_PATH,
-        DataFile.FILE_FORMAT,
-        required(
-            DataFile.PARTITION_ID, DataFile.PARTITION_NAME, partitionType, DataFile.PARTITION_DOC),
-        DataFile.RECORD_COUNT,
-        DataFile.FILE_SIZE,
-        DataFile.COLUMN_SIZES,
-        DataFile.VALUE_COUNTS,
-        DataFile.NULL_VALUE_COUNTS,
-        DataFile.NAN_VALUE_COUNTS,
-        DataFile.LOWER_BOUNDS,
-        DataFile.UPPER_BOUNDS,
-        DataFile.KEY_METADATA,
-        DataFile.SPLIT_OFFSETS,
-        DataFile.EQUALITY_IDS,
-        DataFile.SORT_ORDER_ID,
-        DataFile.FIRST_ROW_ID,
-        DataFile.REFERENCED_DATA_FILE,
-        DataFile.CONTENT_OFFSET,
-        DataFile.CONTENT_SIZE);
+    List<Types.NestedField> fields = Lists.newArrayList();
+    fields.add(DataFile.CONTENT.asRequired());
+    fields.add(DataFile.FILE_PATH);
+    fields.add(DataFile.FILE_FORMAT);
+    if (!partitionType.fields().isEmpty()) {

Review Comment:
   We need to omit this field if we are using parquet because it doesn't support the empty struct



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, Parquet: Allow for Writing Parquet/Avro Manifests in V4 [iceberg]

Posted by "nastra (via GitHub)" <gi...@apache.org>.
nastra commented on code in PR #15634:
URL: https://github.com/apache/iceberg/pull/15634#discussion_r3099390523


##########
core/src/main/java/org/apache/iceberg/BaseFile.java:
##########
@@ -581,9 +584,33 @@ private static <K, V> Map<K, V> copyMap(Map<K, V> map, Set<K> keys) {
 
   private static Map<Integer, ByteBuffer> copyByteBufferMap(
       Map<Integer, ByteBuffer> map, Set<Integer> keys) {
-    return SerializableByteBufferMap.wrap(copyMap(map, keys));
+    if (map == null) {
+      return null;
+    }
+
+    // This is required as long as we have Map<Integer, ByteBuffer> in the API since Parquet is
+    // re-using buffers.
+    Map<Integer, ByteBuffer> deepCopy = Maps.newHashMapWithExpectedSize(map.size());

Review Comment:
   nit: maybe worth putting this into a `deepCopyMap` method



##########
core/src/main/java/org/apache/iceberg/V4Metadata.java:
##########
@@ -278,28 +279,35 @@ static Schema wrapFileSchema(Types.StructType fileSchema) {
   }
 
   static Types.StructType fileType(Types.StructType partitionType) {
-    return Types.StructType.of(
-        DataFile.CONTENT.asRequired(),
-        DataFile.FILE_PATH,
-        DataFile.FILE_FORMAT,
-        required(
-            DataFile.PARTITION_ID, DataFile.PARTITION_NAME, partitionType, DataFile.PARTITION_DOC),
-        DataFile.RECORD_COUNT,
-        DataFile.FILE_SIZE,
-        DataFile.COLUMN_SIZES,
-        DataFile.VALUE_COUNTS,
-        DataFile.NULL_VALUE_COUNTS,
-        DataFile.NAN_VALUE_COUNTS,
-        DataFile.LOWER_BOUNDS,
-        DataFile.UPPER_BOUNDS,
-        DataFile.KEY_METADATA,
-        DataFile.SPLIT_OFFSETS,
-        DataFile.EQUALITY_IDS,
-        DataFile.SORT_ORDER_ID,
-        DataFile.FIRST_ROW_ID,
-        DataFile.REFERENCED_DATA_FILE,
-        DataFile.CONTENT_OFFSET,
-        DataFile.CONTENT_SIZE);
+    List<Types.NestedField> fields = Lists.newArrayList();

Review Comment:
   minor: might be worth using a List Builder instead of adding elements one by one and causing list size to grow/expand



##########
core/src/test/java/org/apache/iceberg/TestSnapshotProducer.java:
##########
@@ -228,6 +229,10 @@ public TableMetadata refresh() {
 
   @TestTemplate
   public void testDefaultManifestCompression() throws IOException {
+    assumeThat(formatVersion)
+        .as("V4 uses Parquet manifests by default; Avro codec checks do not apply")
+        .isLessThan(TableMetadata.MIN_FORMAT_VERSION_PARQUET_MANIFESTS);

Review Comment:
   nit: maybe let's rename the test method to something like `testDefaultAvroManifestCompression()` to make this clearer



##########
core/src/test/java/org/apache/iceberg/TestSnapshotProducer.java:
##########
@@ -236,6 +241,10 @@ public void testDefaultManifestCompression() throws IOException {
 
   @TestTemplate
   public void testManifestCompressionFromTableProperty() throws IOException {
+    assumeThat(formatVersion)
+        .as("V4 uses Parquet manifests by default; Avro codec checks do not apply")
+        .isLessThan(TableMetadata.MIN_FORMAT_VERSION_PARQUET_MANIFESTS);

Review Comment:
   same as above



##########
parquet/src/main/java/org/apache/iceberg/parquet/ParquetValueReaders.java:
##########
@@ -847,7 +849,8 @@ protected List<E> newListData(List<E> reuse) {
       }
 
       if (reuse != null) {
-        this.lastList = reuse;
+        // reuse containers may come from a different reader (e.g. Avro) with incompatible types
+        this.lastList = reuse instanceof ArrayList ? reuse : null;

Review Comment:
   I think the check here and below is too specific. Maybe we should check for known immutable / unmodifiable collections instead?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, Parquet: Allow for Writing Parquet/Avro Manifests in V4 [iceberg]

Posted by "RussellSpitzer (via GitHub)" <gi...@apache.org>.
RussellSpitzer commented on PR #15634:
URL: https://github.com/apache/iceberg/pull/15634#issuecomment-4522777548

   Thanks y'all. Note this is not a binding decision for V4, just the capability in the library. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, Parquet: Allow for Writing Parquet/Avro Manifests in V4 [iceberg]

Posted by "RussellSpitzer (via GitHub)" <gi...@apache.org>.
RussellSpitzer merged PR #15634:
URL: https://github.com/apache/iceberg/pull/15634


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, Parquet: Allow for Writing Parquet/Avro Manifests in V4 [iceberg]

Posted by "RussellSpitzer (via GitHub)" <gi...@apache.org>.
RussellSpitzer commented on code in PR #15634:
URL: https://github.com/apache/iceberg/pull/15634#discussion_r3112619574


##########
core/src/main/java/org/apache/iceberg/V4Metadata.java:
##########
@@ -278,28 +279,35 @@ static Schema wrapFileSchema(Types.StructType fileSchema) {
   }
 
   static Types.StructType fileType(Types.StructType partitionType) {
-    return Types.StructType.of(
-        DataFile.CONTENT.asRequired(),
-        DataFile.FILE_PATH,
-        DataFile.FILE_FORMAT,
-        required(
-            DataFile.PARTITION_ID, DataFile.PARTITION_NAME, partitionType, DataFile.PARTITION_DOC),
-        DataFile.RECORD_COUNT,
-        DataFile.FILE_SIZE,
-        DataFile.COLUMN_SIZES,
-        DataFile.VALUE_COUNTS,
-        DataFile.NULL_VALUE_COUNTS,
-        DataFile.NAN_VALUE_COUNTS,
-        DataFile.LOWER_BOUNDS,
-        DataFile.UPPER_BOUNDS,
-        DataFile.KEY_METADATA,
-        DataFile.SPLIT_OFFSETS,
-        DataFile.EQUALITY_IDS,
-        DataFile.SORT_ORDER_ID,
-        DataFile.FIRST_ROW_ID,
-        DataFile.REFERENCED_DATA_FILE,
-        DataFile.CONTENT_OFFSET,
-        DataFile.CONTENT_SIZE);
+    List<Types.NestedField> fields = Lists.newArrayList();

Review Comment:
   Sounds good to me, All of this should be temporary until we get Anoop's pr in.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, Parquet: Allow for Writing Parquet/Avro Manifests in V4 [iceberg]

Posted by "RussellSpitzer (via GitHub)" <gi...@apache.org>.
RussellSpitzer commented on code in PR #15634:
URL: https://github.com/apache/iceberg/pull/15634#discussion_r3120385719


##########
core/src/main/java/org/apache/iceberg/ManifestWriter.java:
##########
@@ -65,7 +67,8 @@ private ManifestWriter(
       Long snapshotId,
       Long firstRowId,
       Map<String, String> writerProperties) {
-    this.file = file.encryptingOutputFile();
+    this.format = FileFormat.fromFileName(file.encryptingOutputFile().location());

Review Comment:
   I think getting it from the extensions is probably fine for now? Just to avoid extending the apis



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, Parquet: Allow for Writing Parquet/Avro Manifests in V4 [iceberg]

Posted by "RussellSpitzer (via GitHub)" <gi...@apache.org>.
RussellSpitzer commented on code in PR #15634:
URL: https://github.com/apache/iceberg/pull/15634#discussion_r3120448552


##########
core/src/main/java/org/apache/iceberg/ManifestWriter.java:
##########
@@ -240,6 +248,18 @@ public ManifestFile toManifestFile() {
         firstRowId);
   }
 
+  private ByteBuffer keyMetadataBuffer() {
+    if (keyMetadata instanceof NativeEncryptionKeyMetadata nativeKeyMetadata

Review Comment:
   Yeah this is ... a bit unfortunate.  It is "native" in terms of Parquet/Avro but it's also the base container for all of our encryption key metadata classes.
   
   The actual "don't use AES" encryption on write code is 
   
   https://github.com/apache/iceberg/pull/15634/changes/BASE..73f5759d3229d45dc7cf3bce6e05129f92eed310#diff-4e8faf21494a38d340335de99357de31cdca2f3f82af495f832f67fc2446ad49R92-R93
   
   Where we cast a StandardEncryptionOutputFile into a NativeEncryptionOutputFile which strips out the AES encryption.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org