feat: Use ClickHouse lightweight deletes#1040
Conversation
|
👋 @29antonioac |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe ClickHouse implementation now generates ChangesClickHouse delete query generation
Estimated code review effort: 2 (Simple) | ~5 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
feat: Use lightweight deletes in ClickHouse
Summary
Replaces
ALTER TABLE ... DELETE WHEREwithDELETE FROM ... WHERE(lightweight delete) in the ClickHousedelete_and_insertmacro.Background
Elementary's
delete_and_insertmacro previously deleted rows in ClickHouse usingALTER TABLE ... DELETE WHERE, which triggers a heavy background mutation. Mutations are resource-intensive — they rewrite entire data parts and can lag behind inserts on large tables, causing contention and slow Elementary runs.Lightweight deletes (
DELETE FROM ... WHERE) became GA in ClickHouse 23.3. They work differently: rows are marked with a bitmask and resolved lazily at merge time, making the delete step significantly faster. Since dbt-clickhouse only supports ClickHouse 25.3+, every supported version has lightweight deletes on by default — no server configuration needed.Changes
macros/utils/table_operations/delete_and_insert.sql—ALTER TABLE ... DELETE WHERE→DELETE FROM ... ON CLUSTER ... WHERE.Testing
Summary by CodeRabbit
DELETE FROMstatements while preserving existing row-matching behavior.