You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2022/04/06 11:26:43 UTC

[GitHub] [iceberg] vanliu-tx opened a new pull request, #4514: feature: row delta delete files were dropped in sequential commits af…

vanliu-tx opened a new pull request, #4514:
URL: https://github.com/apache/iceberg/pull/4514

   …ter table format updated to v2 #33
   
   Closing #4513 


-- 
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


[GitHub] [iceberg] rdblue merged pull request #4514: Core: row delta delete files were dropped in sequential commits af…

Posted by GitBox <gi...@apache.org>.
rdblue merged PR #4514:
URL: https://github.com/apache/iceberg/pull/4514


-- 
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


[GitHub] [iceberg] rdblue commented on a diff in pull request #4514: Core: row delta delete files were dropped in sequential commits af…

Posted by GitBox <gi...@apache.org>.
rdblue commented on code in PR #4514:
URL: https://github.com/apache/iceberg/pull/4514#discussion_r849936103


##########
core/src/main/java/org/apache/iceberg/MergingSnapshotProducer.java:
##########
@@ -690,7 +690,7 @@ public List<ManifestFile> apply(TableMetadata base) {
         base.schema(), current != null ? current.dataManifests() : null);
     long minDataSequenceNumber = filtered.stream()
         .map(ManifestFile::minSequenceNumber)
-        .filter(seq -> seq > 0) // filter out unassigned sequence numbers in rewritten manifests
+        .filter(seq -> seq >= 0) // filter out unassigned sequence numbers in rewritten manifests

Review Comment:
   Is this `filter` call even needed? If we need to keep results with sequence number 0, then it seems like we should just remove it. Everything should match that filter.



-- 
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


[GitHub] [iceberg] rdblue commented on a diff in pull request #4514: Core: row delta delete files were dropped in sequential commits af…

Posted by GitBox <gi...@apache.org>.
rdblue commented on code in PR #4514:
URL: https://github.com/apache/iceberg/pull/4514#discussion_r847490474


##########
core/src/test/java/org/apache/iceberg/TestV1ToV2RowDeltaDelete.java:
##########
@@ -0,0 +1,240 @@
+/*
+ * 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.util.List;
+import org.apache.iceberg.relocated.com.google.common.collect.Iterables;
+import org.apache.iceberg.relocated.com.google.common.collect.Lists;
+import org.apache.iceberg.relocated.com.google.common.collect.Sets;
+import org.junit.Assert;
+import org.junit.Test;
+
+import static org.apache.iceberg.expressions.Expressions.bucket;
+import static org.apache.iceberg.expressions.Expressions.equal;
+
+public class TestV1ToV2RowDeltaDelete extends TableTestBase {
+
+  public TestV1ToV2RowDeltaDelete() {
+    super(1 /* table format version */);
+  }
+
+  static final DeleteFile FILE_A_POS_1 = FileMetadata.deleteFileBuilder(SPEC)
+      .ofPositionDeletes()
+      .withPath("/path/to/data-a-pos-deletes.parquet")
+      .withFileSizeInBytes(10)
+      .withPartition(FILE_A.partition())
+      .withRecordCount(1)
+      .build();
+
+  static final DeleteFile FILE_A_EQ_1 = FileMetadata.deleteFileBuilder(SPEC)
+      .ofEqualityDeletes()
+      .withPath("/path/to/data-a-eq-deletes.parquet")
+      .withFileSizeInBytes(10)
+      .withPartition(FILE_A.partition())
+      .withRecordCount(1)
+      .build();
+
+  private void verifyManifestSequenceNumber(ManifestFile mf, long sequenceNum, long minSequenceNum) {
+    Assert.assertEquals("sequence number should be " + sequenceNum,
+        mf.sequenceNumber(), sequenceNum);
+    Assert.assertEquals("min sequence number should be " + minSequenceNum,
+        mf.minSequenceNumber(), minSequenceNum);
+  }
+
+  @Test
+  public void testPartitionedTableWithPartitionEqDeletes() {
+    table.newAppend()
+        .appendFile(FILE_A)
+        .appendFile(FILE_B)
+        .appendFile(FILE_C)
+        .commit();
+
+    List<ManifestFile> dataManifests = table.currentSnapshot().dataManifests();
+    List<ManifestFile> deleteManifests = table.currentSnapshot().deleteManifests();
+    Assert.assertEquals("Should have one data manifest file",
+        1, dataManifests.size());
+    Assert.assertEquals("Should have zero delete manifest file",
+        0, deleteManifests.size());
+    ManifestFile dataManifest = dataManifests.get(0);
+    verifyManifestSequenceNumber(dataManifest, 0, 0);
+
+    // update table version to 2
+    TableOperations ops = ((BaseTable) table).operations();
+    TableMetadata base = ops.current();
+    ops.commit(base, base.upgradeToFormatVersion(2));
+
+    table.newRowDelta()
+        .addDeletes(FILE_A_EQ_1)
+        .commit();
+
+    dataManifests = table.currentSnapshot().dataManifests();
+    deleteManifests = table.currentSnapshot().deleteManifests();
+    Assert.assertEquals("Should have one data manifest file",
+        1, dataManifests.size());
+    Assert.assertEquals("Should have one delete manifest file",
+        1, deleteManifests.size());
+    Assert.assertEquals(dataManifest, dataManifests.get(0)); // data manifest not changed
+    ManifestFile deleteManifest = deleteManifests.get(0);
+    verifyManifestSequenceNumber(deleteManifest, 1, 1);
+    List<FileScanTask> tasks = Lists.newArrayList(table.newScan().planFiles().iterator());
+    Assert.assertEquals("Should have three task", 3, tasks.size());
+    FileScanTask task = tasks.get(0);

Review Comment:
   This should not assume that the task for FILE_A is produced first. Instead, this should find the task by 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


[GitHub] [iceberg] kbendick commented on a diff in pull request #4514: feature: row delta delete files were dropped in sequential commits af…

Posted by GitBox <gi...@apache.org>.
kbendick commented on code in PR #4514:
URL: https://github.com/apache/iceberg/pull/4514#discussion_r844116305


##########
core/src/test/java/org/apache/iceberg/TestV1ToV2RowDeltaDelete.java:
##########
@@ -0,0 +1,202 @@
+/*
+ * 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.util.List;
+import org.apache.iceberg.relocated.com.google.common.collect.Iterables;
+import org.apache.iceberg.relocated.com.google.common.collect.Lists;
+import org.apache.iceberg.relocated.com.google.common.collect.Sets;
+import org.junit.Assert;
+import org.junit.Test;
+
+import static org.apache.iceberg.expressions.Expressions.bucket;
+import static org.apache.iceberg.expressions.Expressions.equal;
+
+public class TestV1ToV2RowDeltaDelete extends TableTestBase {
+
+  public TestV1ToV2RowDeltaDelete() {
+    super(1 /* table format version */);
+  }
+
+  static final DeleteFile FILE_A_POS_1 = FileMetadata.deleteFileBuilder(SPEC)
+      .ofPositionDeletes()
+      .withPath("/path/to/data-a-pos-deletes.parquet")
+      .withFileSizeInBytes(10)
+      .withPartition(FILE_A.partition())
+      .withRecordCount(1)
+      .build();
+
+  static final DeleteFile FILE_A_EQ_1 = FileMetadata.deleteFileBuilder(SPEC)
+      .ofEqualityDeletes()
+      .withPath("/path/to/data-a-eq-deletes.parquet")
+      .withFileSizeInBytes(10)
+      .withPartition(FILE_A.partition())
+      .withRecordCount(1)
+      .build();
+
+
+  @Test
+  public void testPartitionedTableWithPartitionEqDeletes() {
+    table.newAppend()
+        .appendFile(FILE_A)
+        .appendFile(FILE_B)
+        .appendFile(FILE_C)
+        .appendFile(FILE_D)
+        .commit();
+
+    // update table version to 2
+    TableOperations ops = ((BaseTable) table).operations();
+    TableMetadata base = ops.current();
+    ops.commit(base, base.upgradeToFormatVersion(2));
+
+    table.newRowDelta()
+        .addDeletes(FILE_A_EQ_1)
+        .commit();
+
+    List<FileScanTask> tasks = Lists.newArrayList(table.newScan().planFiles().iterator());
+    Assert.assertEquals("Should have one task", 4, tasks.size());
+
+    FileScanTask task = tasks.get(0);
+    Assert.assertEquals("Should have one associated delete file",
+        1, task.deletes().size());
+    Assert.assertEquals("Should have only pos delete file",
+        FILE_A_EQ_1.path(), task.deletes().get(0).path());
+
+    table.newDelete().deleteFile(FILE_B).commit();
+    tasks = Lists.newArrayList(table.newScan().planFiles().iterator());
+    Assert.assertEquals("Should have one task", 3, tasks.size());

Review Comment:
   Nit: `Should have three tasks`.



##########
core/src/test/java/org/apache/iceberg/TestV1ToV2RowDeltaDelete.java:
##########
@@ -0,0 +1,202 @@
+/*
+ * 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.util.List;
+import org.apache.iceberg.relocated.com.google.common.collect.Iterables;
+import org.apache.iceberg.relocated.com.google.common.collect.Lists;
+import org.apache.iceberg.relocated.com.google.common.collect.Sets;
+import org.junit.Assert;
+import org.junit.Test;
+
+import static org.apache.iceberg.expressions.Expressions.bucket;
+import static org.apache.iceberg.expressions.Expressions.equal;
+
+public class TestV1ToV2RowDeltaDelete extends TableTestBase {
+
+  public TestV1ToV2RowDeltaDelete() {
+    super(1 /* table format version */);
+  }
+
+  static final DeleteFile FILE_A_POS_1 = FileMetadata.deleteFileBuilder(SPEC)
+      .ofPositionDeletes()
+      .withPath("/path/to/data-a-pos-deletes.parquet")
+      .withFileSizeInBytes(10)
+      .withPartition(FILE_A.partition())
+      .withRecordCount(1)
+      .build();
+
+  static final DeleteFile FILE_A_EQ_1 = FileMetadata.deleteFileBuilder(SPEC)
+      .ofEqualityDeletes()
+      .withPath("/path/to/data-a-eq-deletes.parquet")
+      .withFileSizeInBytes(10)
+      .withPartition(FILE_A.partition())
+      .withRecordCount(1)
+      .build();
+
+
+  @Test
+  public void testPartitionedTableWithPartitionEqDeletes() {
+    table.newAppend()
+        .appendFile(FILE_A)
+        .appendFile(FILE_B)
+        .appendFile(FILE_C)
+        .appendFile(FILE_D)
+        .commit();
+
+    // update table version to 2
+    TableOperations ops = ((BaseTable) table).operations();
+    TableMetadata base = ops.current();
+    ops.commit(base, base.upgradeToFormatVersion(2));
+
+    table.newRowDelta()
+        .addDeletes(FILE_A_EQ_1)
+        .commit();
+
+    List<FileScanTask> tasks = Lists.newArrayList(table.newScan().planFiles().iterator());
+    Assert.assertEquals("Should have one task", 4, tasks.size());
+
+    FileScanTask task = tasks.get(0);
+    Assert.assertEquals("Should have one associated delete file",
+        1, task.deletes().size());
+    Assert.assertEquals("Should have only pos delete file",
+        FILE_A_EQ_1.path(), task.deletes().get(0).path());
+
+    table.newDelete().deleteFile(FILE_B).commit();
+    tasks = Lists.newArrayList(table.newScan().planFiles().iterator());
+    Assert.assertEquals("Should have one task", 3, tasks.size());
+    Assert.assertEquals("Should have one associated delete file",
+        1, tasks.get(0).deletes().size());
+
+    // row delta delete-file will be dropped because minDataSequenceNumber calculated is wrong
+    // in the second commit.
+    table.newDelete().deleteFile(FILE_C).commit();
+    tasks = Lists.newArrayList(table.newScan().planFiles().iterator());
+    Assert.assertEquals("Should have one task", 2, tasks.size());

Review Comment:
   Nit: Wrong number of tasks in assertion statement.



##########
core/src/test/java/org/apache/iceberg/TestV1ToV2RowDeltaDelete.java:
##########
@@ -0,0 +1,202 @@
+/*
+ * 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.util.List;
+import org.apache.iceberg.relocated.com.google.common.collect.Iterables;
+import org.apache.iceberg.relocated.com.google.common.collect.Lists;
+import org.apache.iceberg.relocated.com.google.common.collect.Sets;
+import org.junit.Assert;
+import org.junit.Test;
+
+import static org.apache.iceberg.expressions.Expressions.bucket;
+import static org.apache.iceberg.expressions.Expressions.equal;
+
+public class TestV1ToV2RowDeltaDelete extends TableTestBase {
+
+  public TestV1ToV2RowDeltaDelete() {
+    super(1 /* table format version */);
+  }
+
+  static final DeleteFile FILE_A_POS_1 = FileMetadata.deleteFileBuilder(SPEC)
+      .ofPositionDeletes()
+      .withPath("/path/to/data-a-pos-deletes.parquet")
+      .withFileSizeInBytes(10)
+      .withPartition(FILE_A.partition())
+      .withRecordCount(1)
+      .build();
+
+  static final DeleteFile FILE_A_EQ_1 = FileMetadata.deleteFileBuilder(SPEC)
+      .ofEqualityDeletes()
+      .withPath("/path/to/data-a-eq-deletes.parquet")
+      .withFileSizeInBytes(10)
+      .withPartition(FILE_A.partition())
+      .withRecordCount(1)
+      .build();
+
+
+  @Test
+  public void testPartitionedTableWithPartitionEqDeletes() {
+    table.newAppend()
+        .appendFile(FILE_A)
+        .appendFile(FILE_B)
+        .appendFile(FILE_C)
+        .appendFile(FILE_D)
+        .commit();
+
+    // update table version to 2
+    TableOperations ops = ((BaseTable) table).operations();
+    TableMetadata base = ops.current();
+    ops.commit(base, base.upgradeToFormatVersion(2));
+
+    table.newRowDelta()
+        .addDeletes(FILE_A_EQ_1)
+        .commit();
+
+    List<FileScanTask> tasks = Lists.newArrayList(table.newScan().planFiles().iterator());
+    Assert.assertEquals("Should have one task", 4, tasks.size());
+
+    FileScanTask task = tasks.get(0);
+    Assert.assertEquals("Should have one associated delete file",
+        1, task.deletes().size());
+    Assert.assertEquals("Should have only pos delete file",
+        FILE_A_EQ_1.path(), task.deletes().get(0).path());
+
+    table.newDelete().deleteFile(FILE_B).commit();
+    tasks = Lists.newArrayList(table.newScan().planFiles().iterator());
+    Assert.assertEquals("Should have one task", 3, tasks.size());
+    Assert.assertEquals("Should have one associated delete file",
+        1, tasks.get(0).deletes().size());
+
+    // row delta delete-file will be dropped because minDataSequenceNumber calculated is wrong
+    // in the second commit.

Review Comment:
   Nit: Does this comment still apply? This is the situation that we're fixing, right?
   
   If I understand correctly, this is what was causing the issue. If this comment is no longer applicable because we've fixed it, we should remove it. Maybe it would make a better comment on the PR?



##########
core/src/test/java/org/apache/iceberg/TestV1ToV2RowDeltaDelete.java:
##########
@@ -0,0 +1,202 @@
+/*
+ * 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.util.List;
+import org.apache.iceberg.relocated.com.google.common.collect.Iterables;
+import org.apache.iceberg.relocated.com.google.common.collect.Lists;
+import org.apache.iceberg.relocated.com.google.common.collect.Sets;
+import org.junit.Assert;
+import org.junit.Test;
+
+import static org.apache.iceberg.expressions.Expressions.bucket;
+import static org.apache.iceberg.expressions.Expressions.equal;
+
+public class TestV1ToV2RowDeltaDelete extends TableTestBase {
+
+  public TestV1ToV2RowDeltaDelete() {
+    super(1 /* table format version */);
+  }
+
+  static final DeleteFile FILE_A_POS_1 = FileMetadata.deleteFileBuilder(SPEC)
+      .ofPositionDeletes()
+      .withPath("/path/to/data-a-pos-deletes.parquet")
+      .withFileSizeInBytes(10)
+      .withPartition(FILE_A.partition())
+      .withRecordCount(1)
+      .build();
+
+  static final DeleteFile FILE_A_EQ_1 = FileMetadata.deleteFileBuilder(SPEC)
+      .ofEqualityDeletes()
+      .withPath("/path/to/data-a-eq-deletes.parquet")
+      .withFileSizeInBytes(10)
+      .withPartition(FILE_A.partition())
+      .withRecordCount(1)
+      .build();
+
+
+  @Test
+  public void testPartitionedTableWithPartitionEqDeletes() {
+    table.newAppend()
+        .appendFile(FILE_A)
+        .appendFile(FILE_B)
+        .appendFile(FILE_C)
+        .appendFile(FILE_D)
+        .commit();
+
+    // update table version to 2
+    TableOperations ops = ((BaseTable) table).operations();
+    TableMetadata base = ops.current();
+    ops.commit(base, base.upgradeToFormatVersion(2));
+
+    table.newRowDelta()
+        .addDeletes(FILE_A_EQ_1)
+        .commit();
+
+    List<FileScanTask> tasks = Lists.newArrayList(table.newScan().planFiles().iterator());
+    Assert.assertEquals("Should have one task", 4, tasks.size());

Review Comment:
   Nit: Wrong number of tasks.



-- 
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


[GitHub] [iceberg] vanliu-tx commented on a diff in pull request #4514: Core: row delta delete files were dropped in sequential commits af…

Posted by GitBox <gi...@apache.org>.
vanliu-tx commented on code in PR #4514:
URL: https://github.com/apache/iceberg/pull/4514#discussion_r850044302


##########
core/src/main/java/org/apache/iceberg/MergingSnapshotProducer.java:
##########
@@ -690,7 +690,7 @@ public List<ManifestFile> apply(TableMetadata base) {
         base.schema(), current != null ? current.dataManifests() : null);
     long minDataSequenceNumber = filtered.stream()
         .map(ManifestFile::minSequenceNumber)
-        .filter(seq -> seq > 0) // filter out unassigned sequence numbers in rewritten manifests
+        .filter(seq -> seq >= 0) // filter out unassigned sequence numbers in rewritten manifests

Review Comment:
   some manifest file's minSequenceNumber is -1, if we remove this line, the minDataSequenceNumber will be -1 in some cases, and fail the validation in dropDeleteFilesOlderThan().
   
   ```
     protected void dropDeleteFilesOlderThan(long sequenceNumber) {
       Preconditions.checkArgument(sequenceNumber >= 0,
           "Invalid minimum data sequence number: %s", sequenceNumber);
       this.minSequenceNumber = sequenceNumber;
     }
   ```



-- 
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


[GitHub] [iceberg] rdblue commented on a diff in pull request #4514: Core: row delta delete files were dropped in sequential commits af…

Posted by GitBox <gi...@apache.org>.
rdblue commented on code in PR #4514:
URL: https://github.com/apache/iceberg/pull/4514#discussion_r847488536


##########
core/src/main/java/org/apache/iceberg/MergingSnapshotProducer.java:
##########
@@ -690,7 +690,7 @@ public List<ManifestFile> apply(TableMetadata base) {
         base.schema(), current != null ? current.dataManifests() : null);
     long minDataSequenceNumber = filtered.stream()
         .map(ManifestFile::minSequenceNumber)
-        .filter(seq -> seq > 0) // filter out unassigned sequence numbers in rewritten manifests
+        .filter(seq -> seq >= 0) // filter out unassigned sequence numbers in rewritten manifests

Review Comment:
   @vanliu-tx, I don't see how this would matter. Sequence number 0 is reserved for v1 files, so when you convert to v2 all of the v1 files have sequence number 0. And in v1, there are no delete files. So reporting a min sequence number of 1 and removing all delete files older than 1 should have no change.



-- 
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


[GitHub] [iceberg] rdblue commented on a diff in pull request #4514: Core: row delta delete files were dropped in sequential commits af…

Posted by GitBox <gi...@apache.org>.
rdblue commented on code in PR #4514:
URL: https://github.com/apache/iceberg/pull/4514#discussion_r850667867


##########
core/src/main/java/org/apache/iceberg/MergingSnapshotProducer.java:
##########
@@ -690,7 +690,7 @@ public List<ManifestFile> apply(TableMetadata base) {
         base.schema(), current != null ? current.dataManifests() : null);
     long minDataSequenceNumber = filtered.stream()
         .map(ManifestFile::minSequenceNumber)
-        .filter(seq -> seq > 0) // filter out unassigned sequence numbers in rewritten manifests
+        .filter(seq -> seq >= 0) // filter out unassigned sequence numbers in rewritten manifests

Review Comment:
   That sounds good to me.



-- 
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


[GitHub] [iceberg] rdblue commented on pull request #4514: Core: row delta delete files were dropped in sequential commits af…

Posted by GitBox <gi...@apache.org>.
rdblue commented on PR #4514:
URL: https://github.com/apache/iceberg/pull/4514#issuecomment-1104397619

   Thanks for fixing this, @vanliu-tx!


-- 
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


[GitHub] [iceberg] rdblue commented on a diff in pull request #4514: Core: row delta delete files were dropped in sequential commits af…

Posted by GitBox <gi...@apache.org>.
rdblue commented on code in PR #4514:
URL: https://github.com/apache/iceberg/pull/4514#discussion_r849926058


##########
core/src/main/java/org/apache/iceberg/MergingSnapshotProducer.java:
##########
@@ -690,7 +690,7 @@ public List<ManifestFile> apply(TableMetadata base) {
         base.schema(), current != null ? current.dataManifests() : null);
     long minDataSequenceNumber = filtered.stream()
         .map(ManifestFile::minSequenceNumber)
-        .filter(seq -> seq > 0) // filter out unassigned sequence numbers in rewritten manifests
+        .filter(seq -> seq >= 0) // filter out unassigned sequence numbers in rewritten manifests

Review Comment:
   Okay, I understand. The `base.lastSequenceNumber()` is what causes this. Thanks!



-- 
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


[GitHub] [iceberg] vanliu-tx commented on a diff in pull request #4514: Core: row delta delete files were dropped in sequential commits af…

Posted by GitBox <gi...@apache.org>.
vanliu-tx commented on code in PR #4514:
URL: https://github.com/apache/iceberg/pull/4514#discussion_r850094458


##########
core/src/main/java/org/apache/iceberg/MergingSnapshotProducer.java:
##########
@@ -690,7 +690,7 @@ public List<ManifestFile> apply(TableMetadata base) {
         base.schema(), current != null ? current.dataManifests() : null);
     long minDataSequenceNumber = filtered.stream()
         .map(ManifestFile::minSequenceNumber)
-        .filter(seq -> seq > 0) // filter out unassigned sequence numbers in rewritten manifests
+        .filter(seq -> seq >= 0) // filter out unassigned sequence numbers in rewritten manifests

Review Comment:
   maybe we can change this line to 



-- 
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


[GitHub] [iceberg] vanliu-tx commented on a diff in pull request #4514: Core: row delta delete files were dropped in sequential commits af…

Posted by GitBox <gi...@apache.org>.
vanliu-tx commented on code in PR #4514:
URL: https://github.com/apache/iceberg/pull/4514#discussion_r847920122


##########
core/src/test/java/org/apache/iceberg/TestV1ToV2RowDeltaDelete.java:
##########
@@ -0,0 +1,240 @@
+/*
+ * 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.util.List;
+import org.apache.iceberg.relocated.com.google.common.collect.Iterables;
+import org.apache.iceberg.relocated.com.google.common.collect.Lists;
+import org.apache.iceberg.relocated.com.google.common.collect.Sets;
+import org.junit.Assert;
+import org.junit.Test;
+
+import static org.apache.iceberg.expressions.Expressions.bucket;
+import static org.apache.iceberg.expressions.Expressions.equal;
+
+public class TestV1ToV2RowDeltaDelete extends TableTestBase {
+
+  public TestV1ToV2RowDeltaDelete() {
+    super(1 /* table format version */);
+  }
+
+  static final DeleteFile FILE_A_POS_1 = FileMetadata.deleteFileBuilder(SPEC)
+      .ofPositionDeletes()
+      .withPath("/path/to/data-a-pos-deletes.parquet")
+      .withFileSizeInBytes(10)
+      .withPartition(FILE_A.partition())
+      .withRecordCount(1)
+      .build();
+
+  static final DeleteFile FILE_A_EQ_1 = FileMetadata.deleteFileBuilder(SPEC)
+      .ofEqualityDeletes()
+      .withPath("/path/to/data-a-eq-deletes.parquet")
+      .withFileSizeInBytes(10)
+      .withPartition(FILE_A.partition())
+      .withRecordCount(1)
+      .build();
+
+  private void verifyManifestSequenceNumber(ManifestFile mf, long sequenceNum, long minSequenceNum) {
+    Assert.assertEquals("sequence number should be " + sequenceNum,
+        mf.sequenceNumber(), sequenceNum);
+    Assert.assertEquals("min sequence number should be " + minSequenceNum,
+        mf.minSequenceNumber(), minSequenceNum);
+  }
+
+  @Test
+  public void testPartitionedTableWithPartitionEqDeletes() {
+    table.newAppend()
+        .appendFile(FILE_A)
+        .appendFile(FILE_B)
+        .appendFile(FILE_C)
+        .commit();
+
+    List<ManifestFile> dataManifests = table.currentSnapshot().dataManifests();
+    List<ManifestFile> deleteManifests = table.currentSnapshot().deleteManifests();
+    Assert.assertEquals("Should have one data manifest file",
+        1, dataManifests.size());
+    Assert.assertEquals("Should have zero delete manifest file",
+        0, deleteManifests.size());
+    ManifestFile dataManifest = dataManifests.get(0);
+    verifyManifestSequenceNumber(dataManifest, 0, 0);
+
+    // update table version to 2
+    TableOperations ops = ((BaseTable) table).operations();
+    TableMetadata base = ops.current();
+    ops.commit(base, base.upgradeToFormatVersion(2));
+
+    table.newRowDelta()
+        .addDeletes(FILE_A_EQ_1)
+        .commit();
+
+    dataManifests = table.currentSnapshot().dataManifests();
+    deleteManifests = table.currentSnapshot().deleteManifests();
+    Assert.assertEquals("Should have one data manifest file",
+        1, dataManifests.size());
+    Assert.assertEquals("Should have one delete manifest file",
+        1, deleteManifests.size());
+    Assert.assertEquals(dataManifest, dataManifests.get(0)); // data manifest not changed
+    ManifestFile deleteManifest = deleteManifests.get(0);
+    verifyManifestSequenceNumber(deleteManifest, 1, 1);
+    List<FileScanTask> tasks = Lists.newArrayList(table.newScan().planFiles().iterator());
+    Assert.assertEquals("Should have three task", 3, tasks.size());
+    FileScanTask task = tasks.get(0);

Review Comment:
   will fix this.



-- 
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


[GitHub] [iceberg] vanliu-tx commented on a diff in pull request #4514: Core: row delta delete files were dropped in sequential commits af…

Posted by GitBox <gi...@apache.org>.
vanliu-tx commented on code in PR #4514:
URL: https://github.com/apache/iceberg/pull/4514#discussion_r850044302


##########
core/src/main/java/org/apache/iceberg/MergingSnapshotProducer.java:
##########
@@ -690,7 +690,7 @@ public List<ManifestFile> apply(TableMetadata base) {
         base.schema(), current != null ? current.dataManifests() : null);
     long minDataSequenceNumber = filtered.stream()
         .map(ManifestFile::minSequenceNumber)
-        .filter(seq -> seq > 0) // filter out unassigned sequence numbers in rewritten manifests
+        .filter(seq -> seq >= 0) // filter out unassigned sequence numbers in rewritten manifests

Review Comment:
   some manifest file's minSequenceNumber is -1, if we remove this line, the minDataSequenceNumber will be -1 in some cases, and fail the validation 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


[GitHub] [iceberg] vanliu-tx commented on pull request #4514: Core: row delta delete files were dropped in sequential commits af…

Posted by GitBox <gi...@apache.org>.
vanliu-tx commented on PR #4514:
URL: https://github.com/apache/iceberg/pull/4514#issuecomment-1094802300

   @rdblue @RussellSpitzer @aokolnychyi  could you help to merge this bug fix?


-- 
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


[GitHub] [iceberg] vanliu-tx commented on a diff in pull request #4514: Core: row delta delete files were dropped in sequential commits af…

Posted by GitBox <gi...@apache.org>.
vanliu-tx commented on code in PR #4514:
URL: https://github.com/apache/iceberg/pull/4514#discussion_r850094458


##########
core/src/main/java/org/apache/iceberg/MergingSnapshotProducer.java:
##########
@@ -690,7 +690,7 @@ public List<ManifestFile> apply(TableMetadata base) {
         base.schema(), current != null ? current.dataManifests() : null);
     long minDataSequenceNumber = filtered.stream()
         .map(ManifestFile::minSequenceNumber)
-        .filter(seq -> seq > 0) // filter out unassigned sequence numbers in rewritten manifests
+        .filter(seq -> seq >= 0) // filter out unassigned sequence numbers in rewritten manifests

Review Comment:
   maybe we can change this line to 
   ```
   .filter(seq -> seq != ManifestWriter.UNASSIGNED_SEQ)
   ```



-- 
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


[GitHub] [iceberg] vanliu-tx commented on pull request #4514: Core: row delta delete files were dropped in sequential commits af…

Posted by GitBox <gi...@apache.org>.
vanliu-tx commented on PR #4514:
URL: https://github.com/apache/iceberg/pull/4514#issuecomment-1091054373

   > Thank you for this contribution @vanliu-tx! This is a great find.
   > 
   > The test is quite extensive. I left a few nits, but mostly I'm wondering if there's any kind of simpler way to test for this, like checking the sequence number of planned files after applying a delete.
   > 
   > It might not be something that can be made much simpler though without refactoring the code more.
   > 
   > cc @rdblue @RussellSpitzer @szehon-ho @jackye1995 you'll likely be interested in this.
   
   added some verification for manifest sequence number and min 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


[GitHub] [iceberg] vanliu-tx commented on a diff in pull request #4514: Core: row delta delete files were dropped in sequential commits af…

Posted by GitBox <gi...@apache.org>.
vanliu-tx commented on code in PR #4514:
URL: https://github.com/apache/iceberg/pull/4514#discussion_r847919934


##########
core/src/main/java/org/apache/iceberg/MergingSnapshotProducer.java:
##########
@@ -690,7 +690,7 @@ public List<ManifestFile> apply(TableMetadata base) {
         base.schema(), current != null ? current.dataManifests() : null);
     long minDataSequenceNumber = filtered.stream()
         .map(ManifestFile::minSequenceNumber)
-        .filter(seq -> seq > 0) // filter out unassigned sequence numbers in rewritten manifests
+        .filter(seq -> seq >= 0) // filter out unassigned sequence numbers in rewritten manifests

Review Comment:
   Assuming the following steps
   1. create v1 table and append some data files.
   2. upgrade to v2 and commit.
   3. append some row-delta delete and commit.
   4. remove one data file and commit.
   5. remove another data file and commit.
   
   ```
       long minDataSequenceNumber = filtered.stream()
           .map(ManifestFile::minSequenceNumber)
           .filter(seq -> seq > 0) // filter out unassigned sequence numbers in rewritten manifests
           .reduce(base.lastSequenceNumber(), Math::min);
   ```
   Because all v1 data files has sequence number 0, the minDataSequenceNumber will use base.lastSequenceNumber() as it's value. In step 4 this value is 1, deleteFilterManager.dropDeleteFilesOlderThan(minDataSequenceNumber) will not drop delete-files in step 3. But in step 5, this value turns to 2, which will drop delete-files in step 3.



-- 
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


[GitHub] [iceberg] rdblue commented on a diff in pull request #4514: Core: row delta delete files were dropped in sequential commits af…

Posted by GitBox <gi...@apache.org>.
rdblue commented on code in PR #4514:
URL: https://github.com/apache/iceberg/pull/4514#discussion_r847495061


##########
core/src/main/java/org/apache/iceberg/MergingSnapshotProducer.java:
##########
@@ -690,7 +690,7 @@ public List<ManifestFile> apply(TableMetadata base) {
         base.schema(), current != null ? current.dataManifests() : null);
     long minDataSequenceNumber = filtered.stream()
         .map(ManifestFile::minSequenceNumber)
-        .filter(seq -> seq > 0) // filter out unassigned sequence numbers in rewritten manifests
+        .filter(seq -> seq >= 0) // filter out unassigned sequence numbers in rewritten manifests

Review Comment:
   The check in `ManifestFilterManager` that uses this value is: `(isDelete && entry.sequenceNumber() > 0 && entry.sequenceNumber() < minSequenceNumber)`
   
   We know that `entry.sequenceNumber()` is non-zero. It shouldn't matter whether `minDataSequenceNumber` is 0 or 1.



-- 
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