Skip to content

fix: preserve null_equals_null flag in eliminate_cross_join rule #16356

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

Merged
merged 1 commit into from
Jun 11, 2025

Conversation

waynexia
Copy link
Member

Which issue does this PR close?

  • Closes #.

Rationale for this change

I found that a join plan created using join_detailed method with null_equals_null set to true will be rewritten to a join plan with null_equals_null set to false. This is because optimizer rule eliminate_cross_join will assemble a Join plan and hardcode a false value. This patch fixes that rule and now it will respect the null_equals_null flag from input plan.

A little more background: In a normal SQL model, JOIN and many other places usually take null != null. But I want to leverage JOIN to "concat" two tables' columns in a PromQL scenario, where I treat null as just an identical vacancy, that requires null = null.

What changes are included in this PR?

A bug fix to eliminate_cross_join plan

Are these changes tested?

I wrote a new unit test case to cover this case.

Are there any user-facing changes?

No.

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
@github-actions github-actions bot added the optimizer Optimizer rules label Jun 10, 2025
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank you @waynexia -- this makes sense to me

I was thinking that we might be able to extract a common pattern for join rewriting here and avoid a similar bug (losing the value of null_equals_null) in other optimizer passes that rewrite joins. However, I don't have any good suggestions on how to improve things

@alamb alamb merged commit df49f9f into apache:main Jun 11, 2025
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
optimizer Optimizer rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants