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

fix: Skip buffered rows which are not joined with streamed side when checking join filter results #12159

Merged
merged 1 commit into from
Aug 26, 2024

Conversation

viirya
Copy link
Member

@viirya viirya commented Aug 25, 2024

Which issue does this PR close?

Closes #.

Rationale for this change

Found a test failure on Spark SQL test suite in apache/datafusion-comet#553 (https://github.com/apache/datafusion-comet/actions/runs/10498306015/job/29082983619?pr=553).

When checking join filter results for buffered rows, we should exclude those rows which are not joined with streamed side (i.e., null slots in buffered_indices). Otherwise, we may wrongly consider those rows passing join filter results and lack of null joined buffered rows as in the test.

What changes are included in this PR?

Are these changes tested?

Are there any user-facing changes?

@github-actions github-actions bot added the physical-expr Physical Expressions label Aug 25, 2024
Comment on lines +1477 to +1482
// If the buffered row is not joined with streamed side,
// skip it.
if buffered_indices.is_null(i) {
continue;
}

Copy link
Member Author

@viirya viirya Aug 25, 2024

Choose a reason for hiding this comment

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

I was trying to duplicate the Spark SQL test but the test failure depends on the data distribution. I cannot make it as same as Spark case.

The test case looks like

select * from (
with left as (
    select N, L from (select unnest(make_array(1, 2, 3, 4)) N, unnest(make_array('A', 'B', 'C', 'D')) L) where N <= 4
), right as (
    select N, L from (select unnest(make_array(1, 2, 3, 4)) N, unnest(make_array('A', 'B', 'C', 'D')) L) where N >= 3
)
select * from left full join right on left.N = right.N and left.N != 3
) order by 1, 2, 3, 4;

I want those values to be in same partition to run sort merge join. So the joined batch looks like:

1 A null null
2 B null null # this and above row wrongly considered passing join filter for buffered row [3, C]
3 C 3 C   # join filter => false
4 D 4 D   # join filter => true

The buffered row [3, C] fails join filter. So it should be output as null joined buffered row, but the two above rows are wrongly considered passing join filter for buffered index 0 (i.e., [3, C]), it will not be output in Comet.

Copy link
Member Author

Choose a reason for hiding this comment

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

The test case in Comet is apache/datafusion-comet#553 (comment)

Copy link
Contributor

@comphead comphead left a comment

Choose a reason for hiding this comment

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

lgtm @viirya I feel for this test would be nice to have a DataFusion test, but you said it depends on data distribution between record batches

@viirya
Copy link
Member Author

viirya commented Aug 26, 2024

Thanks @comphead

@viirya
Copy link
Member Author

viirya commented Aug 26, 2024

Let me merge this to unblock apache/datafusion-comet#553.

@viirya viirya merged commit dff590b into apache:main Aug 26, 2024
25 checks passed
@viirya viirya deleted the fix_null_indices branch August 26, 2024 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
physical-expr Physical Expressions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants