Skip to content

fix: Tuple IN null semantics for struct comparisons#21054

Open
xiedeyantu wants to merge 2 commits intoapache:mainfrom
xiedeyantu:fix-struct-in
Open

fix: Tuple IN null semantics for struct comparisons#21054
xiedeyantu wants to merge 2 commits intoapache:mainfrom
xiedeyantu:fix-struct-in

Conversation

@xiedeyantu
Copy link
Member

@xiedeyantu xiedeyantu commented Mar 19, 2026

Which issue does this PR close?

  • No issue linked yet.

Rationale for this change

This PR corrects IN evaluation for tuple/struct comparisons when a candidate row contains NULL in one or more fields.

For example:

SELECT struct(7521, 30) IN (struct(7521, NULL)) 

now returns NULL instead of false.

This matches standard SQL three-valued logic and aligns DataFusion with PostgreSQL behavior.

What changes are included in this PR?

  • Update tuple/struct IN evaluation to preserve null semantics for nested fields
  • Add a regression test in datafusion/physical-expr
  • Add a sqllogictest case to cover the SQL-level behavior

Are these changes tested?

Yes.

  • Unit tests cover the physical expression behavior
  • Sqllogictest coverage verifies the SQL-level result

Are there any user-facing changes?

Yes.

Tuple/struct IN now returns NULL when nested NULLs are involved, matching PostgreSQL behavior.

@github-actions github-actions bot added physical-expr Changes to the physical-expr crates sqllogictest SQL Logic Tests (.slt) labels Mar 19, 2026
@xiedeyantu xiedeyantu marked this pull request as draft March 19, 2026 15:26
@xiedeyantu xiedeyantu marked this pull request as draft March 19, 2026 15:26
@xiedeyantu xiedeyantu marked this pull request as draft March 19, 2026 15:26
@xiedeyantu xiedeyantu marked this pull request as ready for review March 19, 2026 15:37
@xiedeyantu
Copy link
Member Author

Hi @alamb , may I ask if this PR of mine is needed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

physical-expr Changes to the physical-expr crates sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant