Skip to content

feat(sql): support null semantics in static IN-list expressions (#1659) - #2515

Open
mini0n-ai wants to merge 1 commit into
getdozer:mainfrom
mini0n-ai:fix/sql-in-clause-null-semantics-1659
Open

mini0n-ai wants to merge 1 commit into
getdozer:mainfrom
mini0n-ai:fix/sql-in-clause-null-semantics-1659

Conversation

@mini0n-ai

Copy link
Copy Markdown

Description

This pull request extends Dozer streaming SQL IN / NOT IN list evaluation with full SQL three-valued logic and NULL semantics, resolving #1659.

Key Changes

  • dozer-sql/expression/src/in_list.rs:
    • Implemented SQL three-valued logic for IN and NOT IN predicates:
      • If expr evaluates to NULL, returns Field::Null.
      • If an exact match is found, returns Field::Boolean(true) immediately regardless of whether NULL values exist elsewhere in the list.
      • If no exact match is found, but the list contains one or more NULL items, returns Field::Null (Unknown).
      • If no match and no NULLs, returns Field::Boolean(false).
      • Inverted negation (NOT IN): NOT (true) -> false, NOT (false) -> true, NOT (null) -> null.
  • dozer-sql/src/expression/tests/in_list.rs:
    • Added exhaustive regression suite test_in_list_with_nulls covering all 12 permutations:
      • 42 IN (NULL) -> Field::Null
      • 42 IN (1, NULL) -> Field::Null
      • 42 IN (1, NULL, 42) -> Field::Boolean(true)
      • 42 NOT IN (1, NULL) -> Field::Null
      • NULL IN (1, 2, 3) -> Field::Null
      • 42 NOT IN (1, 2, 3) -> Field::Boolean(true)
      • 42 NOT IN (1, 2, 3, 42) -> Field::Boolean(false)
      • 42 NOT IN (1, 2, 3, 42, NULL) -> Field::Boolean(false)
      • Dynamic column evaluation with NULL in record and NULL in value list.

Verification

All 215 tests in dozer-sql and 27 tests in dozer-sql-expression pass cleanly:

cargo test -p dozer-sql
cargo test -p dozer-sql-expression
# test result: ok. 215 passed; 0 failed
# test result: ok. 27 passed; 0 failed

/claim #1659
Resolves #1659

Payout Wallet (Base L2): 0x46D5318E4397cFcBED06a235c1604E473682Ea1F

@CLAassistant

CLAassistant commented Sep 10, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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.

Support for IN clause in streaming SQL

2 participants