Skip to content

Conversation

@jonathanc-n
Copy link
Contributor

Which issue does this PR close?

Rationale for this change

What changes are included in this PR?

Removes the second recursive traversal inside LogicalPlan::Join, it was causing duplicate filters to pop up when gathering filters. Not sure what the reasoning for this second right side traversal was in the first place.

Are these changes tested?

Are there any user-facing changes?

@github-actions github-actions bot added the sql SQL Planner label Sep 2, 2025
@github-actions github-actions bot added the core Core DataFusion crate label Sep 2, 2025
Copy link
Contributor

@nuno-faria nuno-faria left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines -699 to -705
self.select_to_sql_recursively(
right_plan.as_ref(),
query,
select,
&mut right_relation,
)?;

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe someone more knowledgeable could provide some context to this repeated call, but since all tests still work there doesn't seem to be a problem.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree -- it seems like a copy/paste bug to me.

My git archeology suggests it came in the initial PR from @backkem

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it came from #13132 actually

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 @jonathanc-n and @nuno-faria for the review

Copy link
Contributor

@Jefffrey Jefffrey left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Comment on lines -699 to -705
self.select_to_sql_recursively(
right_plan.as_ref(),
query,
select,
&mut right_relation,
)?;

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it came from #13132 actually

@Jefffrey Jefffrey merged commit 051269e into apache:main Sep 5, 2025
28 checks passed
destrex271 pushed a commit to destrex271/datafusion that referenced this pull request Sep 5, 2025
* fix: Remove duplicate filter from `CrossJoin` unparsing

* move test

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

Labels

core Core DataFusion crate sql SQL Planner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unparsing of CROSS JOINs with filters is generating incorrect queries

4 participants