How delete operation works in a Delta Lake table.
_delta_log
) and deletion vectors to mark rows as invalid without physically rewriting the entire Parquet file. Letβs walk through an example to understand what happens step by step.
1.parquet
: Contains rows (1, "Arun")
and (2, "Bala")
.2.parquet
: Contains row (3, "Raj")
._delta_log
) has two entries:
0.json
: Records the creation of 1.parquet
.1.json
: Records the addition of 2.parquet
.id=2
.
id | name |
---|---|
1 | Arun |
2 | Bala |
3 | Raj |
0.json
: 1.parquet
is added.1.json
: 2.parquet
is added.id=2
, the following happens:
Delete operation on a delta table
id=2
is located in 1.parquet
.
id=2
as invalid in 1.parquet
. This avoids rewriting the entire file.
2.json
) is created to record the changes:
1.parquet
is βremovedβ (marked as invalid for the row with id=2
).1.parquet
is βre-addedβ with a deletion vector specifying that the row with id=2
should be excluded.1.parquet
: Contains the original rows (1, "Arun")
and (2, "Bala")
, but the row with id=2
is marked as invalid.2.parquet
: Contains the original row (3, "Raj")
._delta_log
) now has three entries:
0.json
: Records the creation of 1.parquet
.1.json
: Records the addition of 2.parquet
.2.json
: Records the deletion (removal and re-addition of 1.parquet
with a deletion vector).1.parquet
(excluding the row with id=2
).2.parquet
.id | name |
---|---|
1 | Arun |
3 | Raj |
1.parquet
. Hereβs why: