Reputation: 75
WHEN TRIED WITH Solutions, there is a vaccum command in delta to remove the old versions from delta table. However, I would like to remove the partion based on the modification date of the partition.
How to perform this efficiently with the delta features and without losing the durability
Upvotes: -1
Views: 97
Reputation: 17534
Read up on time travel and vacuuming.
DELETE
command will delete the data from current/latest version of the table (say v10) and create a new version (say v11), which becomes the current/latest version. By default you interact with a table (e.g. SELECT * from table
) you're interacting with v11. You can interact with an older version of the table if you want as well, as long as that version exists. E.g. SELECT * from table VERSION AS OF v8
Note the versions are actually numbers (8, 10, 11) not text (v8, v10, v11).
VACUUM
deletes older "versions" (snapshots) of the table, e.g. v10. After you vacuum, you lose the ability to time travel to the deleted versions of the table.
Upvotes: 1
Reputation: 15283
You're mixing up two different things here:
VACUUM
does).In your case, there's no built-in way to remove partitions based on the modification date directly. A good workaround would be to add a new column to your table to track the "update timestamp" (basically your modification date).
Once you have that, you can simply run a DELETE
query like this:
DELETE FROM your_table
WHERE update_date < '2024-11-30';
Delta Lake supports standard DML commands like DELETE
, so this works natively without any additional setup.
If you can't add a new column, you'll need to extract some other information to identify the rows you want to remove. If the partition date itself is sufficient, you can use it and perform a simple DELETE
.
Upvotes: 1