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/01/11 06:17:00 UTC

[GitHub] [iceberg] powerzhangquan commented on a change in pull request #3432: Doc: add a page to explain row-level deletes

powerzhangquan commented on a change in pull request #3432:
URL: https://github.com/apache/iceberg/pull/3432#discussion_r781784823



##########
File path: site/docs/row-level-deletes.md
##########
@@ -0,0 +1,190 @@
+<!--
+ - 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.
+ -->
+
+# Row-Level Deletes
+
+Iceberg supports metadata-based deletion through the `DeleteFiles` interface.
+It allows you to quickly delete a specific file or any file that might match a given expression without the need to read or write any data in the table.
+
+Row-level deletes target more complicated use cases such as general data protection regulation (GDPR).
+Copy-on-write and merge-on-read are two different approaches to handle row-level delete operations. Here are their definitions in Iceberg:
+
+- **copy-on-write**: a delete directly rewrites all the affected data files.
+- **merge-on-read**: delete information is encoded in the form of _delete files_. The table reader can apply all delete information at read time.
+
+Overall, copy-on-write is more efficient in reading data, whereas merge-on-read is more efficient in writing deletes, but requires more maintenance and tuning to be performant in reading data with deletes.
+Users can choose to use **both** copy-on-write and merge-on-read for the same Iceberg table based on different situations. 
+For example, a time-partitioned table can have newer partitions maintained with the merge-on-read approach through a streaming pipeline,
+and older partitions maintained with the copy-on-write approach to apply less frequent GDPR deletes from batch ETL jobs.
+
+There are use cases that could only be supported by one approach such as change data capture (CDC).
+There are also limitations for different compute engines that lead them to prefer one approach over another.
+Please check out the documentation of the specific compute engines to see the details of their capabilities related to row-level deletes.
+This article will focus on explaining Iceberg's core design of copy-on-write and merge-on-read.
+
+!!!Note
+    Update is modeled as a delete with an insert within the same transaction in Iceberg, so this article only explains delete-related concepts. 
+
+## Copy-on-write
+
+In the copy-on-write approach, given a user's delete requirement, the write process would search for all the affected data files and perform a rewrite operation.
+
+For example, consider an unpartitioned table with schema `(id bigint, category string, data string)` that has the following files:
+
+```
+file A: (1, 'c1', 'data1'), (2, 'c1', 'data2')
+file B: (3, 'c2', 'data1'), (4, 'c2', 'data2')
+file C: (5, 'c3', 'data3'), (6, 'c3', 'data2')
+```
+
+A copy-on-write deletion of `data='data1'` can rewrite files A and B into a new file D. D contains the rows that were not deleted from files A and B. The table after the deletion looks like:
+
+```
+file C: (5, 'c3', 'data3'), (6, 'c3', 'data2')
+file D: (2, 'c1', 'data2'), (4, 'c2', 'data2')
+```
+
+There is no effect on read side in the copy-on-write approach.
+
+## Merge-on-read
+
+### Definitions
+
+Iceberg supports 2 different types of row-level delete files: **position deletes** and **equality deletes**.
+The **sequence number** concept is also needed to describe the relative age of data and delete files.
+If you are unfamiliar with these concepts, please read the [row-level deletes](../spec/#row-level-deletes) and [sequence numbers](../spec/#sequence-numbers) sections in the Iceberg spec for more information before proceeding.

Review comment:
       I tried to open two links 'row-level deletes' and 'sequence numbers', but I got 404, the path configuration should be '../spec.md#row-level-deletes' and '../spec.md# sequence-numbers'




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