Skip to content
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

Subquery Unnesting Agg NULL case workarounds #257

Merged
merged 29 commits into from
Dec 8, 2024
Merged

Conversation

jurplel
Copy link
Member

@jurplel jurplel commented Dec 7, 2024

  • Add an outer join with the deduplicated "left side", and a corresponding projection node, to pass along NULL values as expected.
  • Add a specific workaround in the projection node to case NULL -> 0 if we have a COUNT(*).

new_outer_join.into_plan_node(),
ListPred::new(
(0..left_schema_size)
.chain(left_schema_size + left_schema_size..left_schema_size + new_agg_schema_size)
Copy link
Member Author

@jurplel jurplel Dec 8, 2024

Choose a reason for hiding this comment

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

This is one thing I am not sure of the correctness of.

The meaning is to take:

  • Everything from the left side
  • Everything from the right side that is not in the left side.

I found this to be correct in all the tests that I wrote.

Copy link
Member

Choose a reason for hiding this comment

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

Everything from the right side that is not in the left side.

Maybe we need to figure out the exact meaning of this -- do you want to know if two columns refer to the same table-column?

Copy link
Member Author

@jurplel jurplel Dec 8, 2024

Choose a reason for hiding this comment

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

Okay, so after thinking about it a bit longer, my description is correct, but it is a bit easier to think about than that:

The right side is going to be the subquery on the right, and the deduplicated part on the left.

The left side is going to be a copy of the deduplicated part that is the left child of the right child.

So, our projection will be the deduplicated copy (that will be outer joined to resolve the null problems) and the non-deduplicated part from the right side.

@jurplel jurplel marked this pull request as ready for review December 8, 2024 17:57
@jurplel jurplel requested a review from skyzh December 8, 2024 17:57
@jurplel jurplel requested a review from yliang412 December 8, 2024 17:58
Copy link
Member

@skyzh skyzh left a comment

Choose a reason for hiding this comment

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

...anyways, let's get thing through as long as they fix things, even if it's not 100% fix, and visit them back later

@jurplel jurplel merged commit 6696706 into main Dec 8, 2024
1 check passed
@jurplel jurplel deleted the bowad/unnest-agg-null-fix branch December 8, 2024 21:36
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