Skip to content

fix: respect ancestor nullability when folding IS NULL/NOT NULL predicates - #995

Draft
wgtmac wants to merge 1 commit into
apache:mainfrom
wgtmac:fix/is-null-ancestor-nullability
Draft

wgtmac wants to merge 1 commit into
apache:mainfrom
wgtmac:fix/is-null-ancestor-nullability

Conversation

@wgtmac

@wgtmac wgtmac commented Oct 10, 2026

Copy link
Copy Markdown
Member

IS NULL and NOT NULL on a required field nested in an optional struct were folded to AlwaysFalse/AlwaysTrue, so scans could prune files that still match: a required field is null whenever its parent is null.

Only fold when the field and all of its ancestors are required, matching Java's UnboundPredicate#bindUnaryOperation.

…cates

A required field nested in an optional struct, list, or map can be null when its
parent is null, so IS NULL and NOT NULL must not be folded for it. Only fold
when the field and all of its ancestors are required, matching Java's
UnboundPredicate#bindUnaryOperation.
Copilot AI balanced review requested due to automatic review settings October 10, 2026 09:56
@wgtmac
wgtmac marked this pull request as draft October 10, 2026 09:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The implementation correctly prevents unsafe pruning and preserves valid folding for fully required paths.

0 open findings

What changed in this PR

Fixes unsafe null-predicate folding for required fields beneath optional ancestors.

Changes:

  • Checks ancestor nullability before constant folding.
  • Adds nested optional/required struct tests.
  • Passes schema context into unary binding.
File Description
src/​iceberg/​expression/​predicate.cc Implements ancestor-aware folding.
src/​iceberg/​expression/​predicate.h Updates unary binding signature.
src/​iceberg/​test/​predicate_test.cc Tests nested nullability behavior.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

This branch has not been deployed

No deployments
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.

2 participants