Skip to content

test: cover nested wrappers and TRY_CAST in physical CASE nullability#65

Merged
friendlymatthew merged 1 commit into
friendlymatthew/fix-case-physical-nullabilityfrom
claude/case-nullability-tests
Jul 23, 2026
Merged

test: cover nested wrappers and TRY_CAST in physical CASE nullability#65
friendlymatthew merged 1 commit into
friendlymatthew/fix-case-physical-nullabilityfrom
claude/case-nullability-tests

Conversation

@adriangb

Copy link
Copy Markdown
Member

Follow-up tests for apache#23844, targeting your branch so they land in the same PR.

Two additions to case_expression_nullability (both run for the nullable and non-nullable column variants):

  • Nested wrappersCAST(-foo) and NOT(NOT(predicate)) confirm unwrap_certainly_null_expr recurses through stacked null-preserving wrappers, so the guarded branch is still proven unreachable-as-null.
  • TRY_CAST stays nullableTRY_CAST is intentionally not unwrapped: it can yield NULL on a failed cast even for a non-null input, so a guarded TRY_CAST branch keeps the CASE nullable. I verified this fails (assert_nullable) if TryCastExpr is added to the unwrapper, so it guards the logical/physical sync invariant against someone unwrapping it on only one side.

cargo test -p datafusion-physical-expr, cargo fmt, and cargo clippy --all-targets --all-features -D warnings all pass on top of your branch.

Feel free to squash into your commit or cherry-pick whatever's useful.

🤖 Generated with Claude Code

Adds unit tests that lock in two properties of unwrap_certainly_null_expr:

- Nested null-preserving wrappers (e.g. CAST(-foo)) are unwrapped
  recursively, so the guarded branch is still proven unreachable-as-null.
- TRY_CAST is intentionally NOT unwrapped: it can yield NULL on a failed
  cast even for a non-null input, so a guarded TRY_CAST branch keeps the
  CASE nullable. This guards the logical/physical sync invariant against
  someone later unwrapping TRY_CAST on only one side.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@friendlymatthew
friendlymatthew merged commit 32d3de6 into friendlymatthew/fix-case-physical-nullability Jul 23, 2026
69 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants