[spark] Add point-delete fast path for primary key DELETE to skip the target table scan - #8837
[spark] Add point-delete fast path for primary key DELETE to skip the target table scan#8837ZZZxDong wants to merge 1 commit into
Conversation
|
|
Good catch, all four points are valid — fixed. The fast path is now gated to DEDUPLICATE tables without NOT NULL non-pk columns (anything else falls back to the scan path), and NULL literals in the condition also fall back so SQL three-valued logic is preserved. Added tests for each case, and rebased onto master to resolve the conflict. |
de85cd1 to
0565f2d
Compare
b2ca4aa to
298ce26
Compare
|
CI caught another case of the same pattern: tables with primary-key indexes (btree/bitmap etc.) build index entries from real field values, so NULL-filled -D rows would leave the deletion invisible to index lookups. Added a third gate — tables with any pk index definition also fall back to the scan path. All tests green now. |
9a61e7c to
fa5662c
Compare
|
The remaining CI failure surfaced a real semantic difference: -D rows from the fast path carry NULL for non-key columns, so incremental / audit_log reads would not see the old field values of deleted rows (the TVF test asserts |
… target table scan
fa5662c to
e81b777
Compare
|
@JingsongLi Thanks for the review! Summarizing the current state since the comments above are scattered:
All four points are addressed, plus two more cases that CI surfaced along the way:
Please review it again when you have time, thanks! |
Purpose
Closes #8836.
Currently
DELETE FROMon a primary-key table always scans the target table to locate matching rows, even when the condition is nothing but primary keys. In that case the matched keys are already fully described by the condition, so we can build the-Drecords directly and skip the scan.This PR adds a fast path to
DeleteFromPaimonTableCommandfor the pk-upsert delete:pk = literal/pk IN (literals)covering all pk columns-Drows from the condition on the driver (capped bydelete.point-delete.max-rows, default 1M, falls back to scan beyond that)pk IN (subquery)covering all pk columnsKeys absent from the table are harmless: their
-Drecords simply merge away in compaction, which matches the semantics of the existing path.Tests
DeletePointFastPathTest: literal IN / equality / composite pk, subquery with single and composite pk (including positionally-renamed columns), fallback cases (non-pk column in condition, pk not fully pinned), delete-then-reinsert. Also ran the existingDeleteFromTableTestsuite (29 tests) — all pass, no behavior change.API and Format
New connector option
delete.point-delete.max-rows(default 1000000). No format change.Documentation
N/A