Skip to content

feat: add NOT, IS NULL and IS NOT NULL expressions - #14

Open
createcentury wants to merge 1 commit into
datafusion-contrib:mainfrom
createcentury:feat/not-is-null-exprs
Open

createcentury wants to merge 1 commit into
datafusion-contrib:mainfrom
createcentury:feat/not-is-null-exprs

Conversation

@createcentury

@createcentury createcentury commented Oct 10, 2026 •

Copy link
Copy Markdown

Summary

This PR adds three boolean-returning expressions to the random expression generator, following the existing BaseExpr / BaseExprWithInfo pattern:

Expression Child signature DataFusion Expr
NOT <bool> [SameAsOutput] (Boolean) Expr::Not
<any> IS NULL [OneOf(all available types)] Expr::IsNull
<any> IS NOT NULL [OneOf(all available types)] Expr::IsNotNull

Generated data already contains NULLs, so these expressions help predicates exercise NULL semantics, which is where the TLP oracles are most useful. The implementation keeps the current best-effort typing approach and adds no validity constraints.

Changes

  • expr_def.rs: add Not, IsNull, IsNotNull to BaseExpr and to_impl()
  • expr_impl.rs: add NotExpr, IsNullExpr, IsNotNullExpr, update the coverage checklist, and add unit tests for the return types and SQL unparsing (NOT v1, v1 IS NULL, v1 IS NOT NULL)
  • tests/integration_test.rs: snapshots updated with cargo insta test --accept. The new enum variants shift the deterministic generation sequence, so the snapshot diff is expected.

Example generated queries

SELECT ...
FROM t0
WHERE 13 IS NOT NULL
SELECT ...
FROM t1
GROUP BY ...
HAVING ([-53] IS NOT NULL)

Testing

  • cargo test: all tests pass
  • Fuzzing run with all four oracles (NoCrash, NestedQueries, TlpWhere, TlpHaving), seed = 7, 20 rounds × 50 queries, compared against main with the same config:
main this PR
Oracle failures 110 97
— value mismatches 0 0
— mixed outcomes (one query errors) 110 97
Non-whitelisted errors 1 1

All oracle failures in both runs are the existing "mixed outcomes" kind discussed in #6. The PR does not introduce any new failure category.

The single non-whitelisted error happens on both branches and is unrelated to this change. It comes from the existing NATURAL JOIN ... ON whitelist entry: the DataFusion 54 parser error now ends with at Line: X, Column: Y, so the Contains("...found: ON\")") pattern no longer matches. I'm happy to send a small follow-up PR for that.

Thanks for reviewing!

Add three boolean-returning expressions to the random expression
generator so that generated predicates exercise NULL semantics:

- NOT <bool>
- <any> IS NULL
- <any> IS NOT NULL

Integration snapshots are updated because the new BaseExpr variants
shift the deterministic generation sequence.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant