Skip to content

Ducklake truncate operator#825

Draft
jprafael wants to merge 8 commits into
duckdb:mainfrom
jprafael:ducklake-truncate-operator
Draft

Ducklake truncate operator#825
jprafael wants to merge 8 commits into
duckdb:mainfrom
jprafael:ducklake-truncate-operator

Conversation

@jprafael
Copy link
Copy Markdown
Contributor

Current implementation of DELETE FROM table or TRUNCATE table scans the entire table to be deleted and captures row_ids in memory which for large tables is expensive.

This is an optimization for the case where the full table needs to be deleted, in which case we can do it by manipulating metadata alone.

This was LLM generated.

Copy link
Copy Markdown
Contributor

@Mytherin Mytherin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Looks good - good idea. Can we add some extra tests?

  • Verify ROLLBACK works correctly
  • Verify transactionality works correctly (i.e. other connections don't yet see the changes)
  • Add tests verifying this works correctly with inlined data
  • Look at the return value of TRUNCATE to verify it's returning the correct number of rows, also when a table already has deletes within a file
  • Verify time travel works

@jprafael jprafael force-pushed the ducklake-truncate-operator branch from 28c03cf to 5e3b0ca Compare March 12, 2026 17:48
@jprafael jprafael changed the title Ducklake truncate operator WIP: Ducklake truncate operator Mar 12, 2026
@jprafael jprafael force-pushed the ducklake-truncate-operator branch from e699b0e to c3f8935 Compare March 12, 2026 18:08
@jprafael jprafael changed the title WIP: Ducklake truncate operator Ducklake truncate operator Mar 12, 2026
@jprafael
Copy link
Copy Markdown
Contributor Author

Thanks! Looks good - good idea. Can we add some extra tests?

  • Verify ROLLBACK works correctly
  • Verify transactionality works correctly (i.e. other connections don't yet see the changes)
  • Add tests verifying this works correctly with inlined data
  • Look at the return value of TRUNCATE to verify it's returning the correct number of rows, also when a table already has deletes within a file
  • Verify time travel works

Thanks for the test pushback! Indeed there were some issues with the code that warranted a rewrite. The new version adds tests for the cases you mentioned and is more organized in the way that DuckLakeTruncate iterates through the data sources (files, inline, local inline). There is also

@jprafael jprafael requested a review from Mytherin March 12, 2026 18:10
@jprafael jprafael force-pushed the ducklake-truncate-operator branch from c3f8935 to d4d987a Compare April 9, 2026 16:28
@jprafael jprafael marked this pull request as draft April 10, 2026 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants