Skip to content

Fix LocalRelTable insert for batched rel creation#412

Merged
adsharma merged 2 commits into
mainfrom
fix/local-rel-table-batched-insert-ids
Apr 21, 2026
Merged

Fix LocalRelTable insert for batched rel creation#412
adsharma merged 2 commits into
mainfrom
fix/local-rel-table-batched-insert-ids

Conversation

@adsharma

Copy link
Copy Markdown
Contributor

Fixes: #378

insert() was implicitly assuming 1 row per call:

  • It read only selVector()[0] for bound node(s).
  • It assigned a temp rel ID to only one position.
  • It pushed only one row index into local CSR index.

But the query can create multiple rels in one vectorized insert call (e.g., two before -> x rows for PO),
so multiple local rels could end up sharing/garbling temp IDs and index bookkeeping.

That explains the duplicated local _ID (...7904)

Fix

  • assign unique local rel IDs for every selected row (base + i)
  • validate bound-node nullability for every row/direction
  • append all rows
  • insert each appended row into each directed index using the matching selection position

 insert() was implicitly assuming 1 row per call:

 - It read only selVector()[0] for bound node(s).
 - It assigned a temp rel ID to only one position.
 - It pushed only one row index into local CSR index.

 But the query can create multiple rels in one vectorized insert call (e.g., two before -> x rows for PO),
 so multiple local rels could end up sharing/garbling temp IDs and index bookkeeping.

 That explains the duplicated local _ID (...7904)

 ### Fix

 - assign unique local rel IDs for every selected row (base + i)
 - validate bound-node nullability for every row/direction
 - append all rows
 - insert each appended row into each directed index using the matching selection position
LocalRelTable::insert() was still assuming aligned non-flat selection
vectors after the previous batched insert fix. In practice, rel
inserts can run with mixed vector states (e.g., flat src/dst vectors
while the rel-id/property vector drives multiple rows), so indexing
selVector()[i] directly on every vector is invalid and can misread/write
rows. This broke merge/create rel paths in CI.

Fix by driving numRowsToAppend from the rel-id vector selection,
and resolving per-row positions per vector: use sel[0] for flat
vectors, sel[i] for unflat vectors. Apply this consistently for
bound-node null checks, local rel-id assignment, and directed index
updates.
@adsharma adsharma force-pushed the fix/local-rel-table-batched-insert-ids branch from a0483c8 to 42b23f4 Compare April 21, 2026 22:45
@adsharma adsharma merged commit d08bf1a into main Apr 21, 2026
4 checks passed
@adsharma adsharma deleted the fix/local-rel-table-batched-insert-ids branch April 21, 2026 23:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Duplicate Rel IDs

1 participant