Skip to content

Use SQL null semantics for DuckDB IN and NOT IN pushdown - #10054

Merged
robert3005 merged 11 commits into
developfrom
rk/duckdb-list-contains
Oct 15, 2026
Merged

robert3005 merged 11 commits into
developfrom
rk/duckdb-list-contains

Conversation

@robert3005

@robert3005 robert3005 commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

DuckDB membership pushdown used Vortex's default null rules, which can make a nonmatch in NOT IN (1, NULL) true. Use SQL null semantics so that result remains unknown and the row is excluded.

@codspeed

codspeed Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Merging this PR will improve performance by 13.19%

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

⚠️ 2 benchmarks measured no execution time

Nothing ran under measurement, usually because the compiler removed the code under test. These results are not comparable, so they count as unchanged.

Preventing compiler optimizations

⚠️ 16 benchmarks spent significant time in system calls

System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.

Measurement and system calls

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 3 improved benchmarks
✅ 2256 untouched benchmarks

Performance Changes

Mode Benchmark BASE HEAD Efficiency
⚡ WallTime threshold_neon[64] 5.2 µs 4.6 µs +13.78%
⚡ WallTime threshold_neon[8] 3.6 µs 3.1 µs +13.13%
⚡ WallTime filter_neon[64] 3.2 µs 2.8 µs +12.68%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing rk/duckdb-list-contains (c97dc82) with develop (c128e99)

Open in CodSpeed

@robert3005
robert3005 removed this pull request from stack #10055 September 25, 2026 14:05
@robert3005
robert3005 force-pushed the rk/list-contains-bindings branch from 2aaa1b6 to 1b63fd8 Compare September 25, 2026 14:06
@robert3005
robert3005 force-pushed the rk/duckdb-list-contains branch from 7f7f687 to 29fa2b0 Compare September 25, 2026 14:06
@robert3005
robert3005 added this pull request to stack #10058 September 25, 2026 14:06
@robert3005
robert3005 removed this pull request from stack #10058 September 25, 2026 14:09
@robert3005
robert3005 force-pushed the rk/list-contains-bindings branch from 1b63fd8 to 3151b45 Compare September 25, 2026 14:09
@robert3005
robert3005 added this pull request to stack #10061 September 25, 2026 14:09
@robert3005
robert3005 force-pushed the rk/duckdb-list-contains branch from 29fa2b0 to adc15ee Compare September 25, 2026 14:09
@robert3005
robert3005 force-pushed the rk/duckdb-list-contains branch from adc15ee to 2535299 Compare September 25, 2026 15:53
@robert3005
robert3005 force-pushed the rk/list-contains-bindings branch from 3151b45 to b6ffdda Compare September 25, 2026 15:53
@robert3005
robert3005 force-pushed the rk/duckdb-list-contains branch from 2535299 to cafd7d2 Compare September 25, 2026 16:28
@robert3005
robert3005 force-pushed the rk/list-contains-bindings branch 2 times, most recently from ed99a18 to 0e3443a Compare September 25, 2026 17:10
@robert3005
robert3005 force-pushed the rk/duckdb-list-contains branch 2 times, most recently from 04bd414 to 459162a Compare September 25, 2026 17:26
@robert3005
robert3005 force-pushed the rk/list-contains-bindings branch 2 times, most recently from 2242462 to 828a8f7 Compare September 25, 2026 20:28
@robert3005
robert3005 force-pushed the rk/duckdb-list-contains branch 2 times, most recently from c0e6065 to 843d57c Compare September 28, 2026 20:43
@robert3005
robert3005 force-pushed the rk/list-contains-bindings branch from 828a8f7 to 3dd8f74 Compare September 28, 2026 20:43
Comment thread vortex-duckdb/src/convert/expr.rs Resolved
@robert3005
robert3005 force-pushed the rk/duckdb-list-contains branch from 843d57c to e4b6598 Compare September 29, 2026 19:13
@robert3005
robert3005 force-pushed the rk/list-contains-bindings branch from 3dd8f74 to 2a51612 Compare September 29, 2026 19:13
@robert3005
robert3005 force-pushed the rk/duckdb-list-contains branch from 2a977a1 to 5b12a0f Compare October 14, 2026 17:32
@robert3005
robert3005 force-pushed the rk/list-contains-bindings branch from 446956a to 6801f5b Compare October 14, 2026 17:32
@robert3005
robert3005 force-pushed the rk/duckdb-list-contains branch 2 times, most recently from 757e4da to 461e8a7 Compare October 14, 2026 18:34
@robert3005
robert3005 force-pushed the rk/list-contains-bindings branch from 856b420 to 2bda1b5 Compare October 14, 2026 18:34
@robert3005
robert3005 removed this pull request from stack #10443 October 14, 2026 18:35
@robert3005
robert3005 changed the base branch from rk/list-contains-bindings to develop October 14, 2026 18:35
robert3005 and others added 4 commits October 15, 2026 11:16
Convert both IN table filters and bound membership expressions through
in_list, so a null set element leaves nonmatches unknown. Decline
nonconstant lists instead of promising conversion and failing later.

Add scan-result and EXPLAIN regressions for nullable sets, views, large
constant lists, and fallback for nonconstant list elements.

Signed-off-by: Robert Kruszewski <[email protected]>
DuckDB IN and NOT IN filters now convert to in_list, which shows
opts=sql_null_semantics in EXPLAIN. Update the expected TPC-H, TPC-DS
and ClickBench plans to match.

The membership pushdown test searched EXPLAIN for "list_contains", but
the scan shows "vortex.list.contains". Search for "sql_null_semantics"
instead, because the EXPLAIN box does not split it across lines.

Signed-off-by: Robert Kruszewski <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@robert3005
robert3005 force-pushed the rk/duckdb-list-contains branch from 461e8a7 to c31d440 Compare October 15, 2026 10:35
@robert3005 robert3005 added the changelog/fix A bug fix label Oct 15, 2026
robert3005 and others added 3 commits October 15, 2026 12:04
Before, any IN whose children could push was accepted, and conversion
failed when a list value was not a constant. The previous fix only
accepted constant lists, which pushed less than before.

Accept the same IN expressions as before and convert all of them.
Constant values go into one in_list. Each nonconstant value becomes an
equality with the element, joined with Kleene OR, which keeps the SQL
null semantics of IN and NOT IN.

Remove a stale TODO on the IN table filter.

Signed-off-by: Robert Kruszewski <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Revert the OR-of-equalities lowering for nonconstant IN values. in_list
already gives SQL semantics for constant lists, and DuckDB keeps IN
expressions with nonconstant values.

Signed-off-by: Robert Kruszewski <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Bring back the conversion of IN values that are not constants to
equalities joined with OR, and explain it. All constants still go into
one in_list with SQL null semantics. Kleene OR keeps the SQL result of
IN and NOT IN when values are null.

Signed-off-by: Robert Kruszewski <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@robert3005
robert3005 marked this pull request as ready for review October 15, 2026 11:09
Signed-off-by: Robert Kruszewski <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

remove this

Signed-off-by: Robert Kruszewski <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Comment on lines 89 to +91
let dtype = scalars[0].dtype().clone();
let list_scalar = Scalar::list(Arc::new(dtype), scalars, Nullability::Nullable);
list_contains(lit(list_scalar), col.clone())
let list_scalar = Scalar::list(Arc::new(dtype), scalars, Nullability::NonNullable);
in_list(col.clone(), lit(list_scalar))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

comment please

robert3005 and others added 2 commits October 15, 2026 12:30
DuckDB's in_clause optimizer rewrites IN lists with nonconstant values
to equalities, so the OR lowering only ran with that optimizer
disabled. Remove it and keep IN pushdown for constant lists, which
in_list converts with SQL null semantics. DuckDB keeps other IN lists.

Signed-off-by: Robert Kruszewski <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Robert Kruszewski <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@robert3005
robert3005 enabled auto-merge (squash) October 15, 2026 11:38
@robert3005
robert3005 merged commit c1a2ca1 into develop Oct 15, 2026
91 checks passed
@robert3005
robert3005 deleted the rk/duckdb-list-contains branch October 15, 2026 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/fix A bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants