Repository navigation
Conversation
DuckDB filters `x IS [NOT] DISTINCT FROM <value>`, and the `IS [NOT] TRUE/FALSE` forms it rewrites to them, failed to bind against a Vortex scan with "cannot convert DUCKDB_VX_EXPR_TYPE_COMPARE_DISTINCT_FROM". `can_push_expression` accepted every comparison, but the converter only knew the operators in `Operator`. Lower them in the converter as `(l IS NULL AND r IS NULL) OR (l IS NOT NULL AND r IS NOT NULL AND l = r)` and its negation. Unlike `=`, this is never NULL, so it stays correct under NOT and OR. Add a sqllogictest that runs on DuckDB and DataFusion and, on DuckDB, asserts that the filter is pushed into the scan. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Ayush Mishra <ayushm1906@gmail.com>
Merging this PR will improve performance by 16.19%2 warnings
Performance Changes
Tip Curious why performance improved? Comment Comparing Footnotes
|
Summary
IS [NOT] DISTINCT FROMfilters fail with a Binder Error on a Vortex scan #11394IS [NOT] DISTINCT FROMfilters fail against a Vortex scan in DuckDB withBinder Error: cannot convert DUCKDB_VX_EXPR_TYPE_COMPARE_DISTINCT_FROM. So doIS [NOT] TRUEandIS [NOT] FALSE, which DuckDB rewrites to them.can_push_expressionaccepts everyBoundComparison, but the converter only handles the six operators inOperator.This lowers the two operators in the converter so the filter is evaluated by the scan.
Changes
vortex-duckdb/src/convert/expr.rs: lowerIS NOT DISTINCT FROMas(l IS NULL AND r IS NULL) OR (l IS NOT NULL AND r IS NOT NULL AND l = r), andIS DISTINCT FROMas its negation. Unlike=, the result is never NULL, so it is correct underNOTandOR.vortex-sqllogictest/slt/is_distinct_from.slt: covers a constant,NULL, column against column,NOT (...)andIS [NOT] TRUE. On DuckDB it also asserts throughEXPLAINthat noFILTERnode remains.Tests
developwith the error above and passes with this change. It also fails if the lowering uses plain=or drops the not-null guards.cargo test -p vortex-duckdb --libandcargo test -p vortex-sqllogictest --test sqllogictestspass; clippy-D warningsand fmt on the pinned nightly are clean.Notes
IS DISTINCT FROMlowers to aNOT(...), which has no zone-map falsification rule, so it is not pruned by zone maps. This is from reading the stats rewrite rules, not from a measurement.AI assistance
Developed with Claude Code (Claude Sonnet 5.5); I reviewed the diff and the test results and stand behind the change.
🤖 Generated with Claude Code