Skip to content

New Null Handling Behavior in Joins: Null Matches Everything #15891

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
tobixdev opened this issue Apr 29, 2025 · 0 comments
Open

New Null Handling Behavior in Joins: Null Matches Everything #15891

tobixdev opened this issue Apr 29, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@tobixdev
Copy link
Contributor

tobixdev commented Apr 29, 2025

Is your feature request related to a problem or challenge?

Building a system that works with graph-like data on DataFusion will stumble upon the need to join the intermediate results of graph patterns. However, null handling is a bit different in these systems compared to SQL.

Usually you combine two intermediary results based on a notion of compatibility instead of strict equality. In these semantics, NULL is compatible with everything. Here is a small table that demonstrates this behavior on a single value:

Lhs Rhs Matches?
NULL NULL Yes
"A" NULL Yes
NULL "A" Yes
"A" "A" Yes
"A" "B" No

Currently, we use UDFs to check for compatibility which can be implemented using a NestedLoopJoinExec as we do not have a "native" equal join condition. Having access to the HashJoin etc. implementation of DataFusion would be great, as we would not have to re-invent the join infrastructure.

Is this something that you'd be interested in having in DF?

Describe the solution you'd like

I propose addressing this problem in three steps:

  1. Replace Join::null_equals_null with an enum JoinNullBehavior (or similar).
  2. Add an additional variant JoinNullBehavior::NullMatchesEverything.
  3. Extending join implementations one-by-one by checking in the planner whether a join implementation is available for the given JoinNullBehavior.

Describe alternatives you've considered

  1. Sticking with NestedLoopJoins
  2. Leaving this behavior downstream

Additional context

Definition of Solution Compatibility in SPARQL 1.1:

This could also be helpful for SQL/PGQ or GQL implementations based on DF.
Related Issues:

@tobixdev tobixdev added the enhancement New feature or request label Apr 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant