Skip to content

Fix wrong rows from rel property IN filters over rel table groups#699

Merged
adsharma merged 1 commit into
LadybugDB:mainfrom
magyargergo:fix-692
Jul 18, 2026
Merged

Fix wrong rows from rel property IN filters over rel table groups#699
adsharma merged 1 commit into
LadybugDB:mainfrom
magyargergo:fix-692

Conversation

@magyargergo

@magyargergo magyargergo commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Fixes #692

Summary

A filter like WHERE r.type IN ['CALLS'] can return wrong rows on a rel table group. A row from one endpoint table came back twice and the row from another endpoint table was dropped. Equality filters on the same data were always correct.

Cause

IN becomes list_contains, which has no native select implementation. The filter falls back to computing a boolean vector and then converting it into selected positions in updateSelectedPos. That conversion skips writing the selection buffer whenever the current selection has size 1, assuming the state is flat. But an unflat scan batch with a single row also takes that shortcut. The caller then calls setToFiltered, which switches the selection vector to the buffer that was never written. The buffer still holds positions from a previous batch, so the filter picks the wrong row. I confirmed this by stepping through the failing query in gdb and watching the selection vector across filter batches.

Fix

Take the shortcut only when the result state is really flat. Unflat single row batches now write the selection buffer like any other batch.

…DB#692)

updateSelectedPos skipped writing the selection buffer whenever the
current selection size was 1, assuming the state is flat. An unflat
chunk with a single row also took that shortcut. The caller then
activated the selection buffer through setToFiltered, exposing
positions left over from a previous batch. A rel property IN filter
over a rel table group could then duplicate a row from one endpoint
table and drop the row from another.

Take the shortcut only when the result state is really flat, so
unflat single row batches write the buffer like any other batch.

Adds a COPY based regression test that reproduces the corruption
deterministically. The new case fails without the fix and passes
with it.
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.

REL TABLE GROUP property IN predicate duplicates rows and omits another endpoint table

2 participants