Skip to content

SortMerge join support for IS NOT DISTINCT FROM.#16003

Merged
gianm merged 5 commits intoapache:masterfrom
gianm:smj-indf
Mar 19, 2024
Merged

SortMerge join support for IS NOT DISTINCT FROM.#16003
gianm merged 5 commits intoapache:masterfrom
gianm:smj-indf

Conversation

@gianm
Copy link
Copy Markdown
Contributor

@gianm gianm commented Feb 29, 2024

The patch adds a "requiredNonNullKeyParts" field to the sortMerge processor, which has the list of key parts that must be nonnull for an equijoin condition to match. Conditions with SQL "=" are present in the list; conditions with SQL "IS NOT DISTINCT FROM" are absent from the list.

The patch adds a "requiredNonNullKeyParts" field to the sortMerge
processor, which has the list of key parts that must be nonnull for
an equijoin condition to match. Conditions with SQL "=" are present in
the list; conditions with SQL "IS NOT DISTINCT FROM" are absent from
the list.
@github-actions github-actions Bot added Area - Batch Ingestion Area - Querying Area - MSQ For multi stage queries - https://github.com/apache/druid/issues/12262 labels Feb 29, 2024
Copy link
Copy Markdown
Contributor

@LakshSingla LakshSingla left a comment

Choose a reason for hiding this comment

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

lgtm! minor comments

Comment on lines +144 to 146
if (keyParts.length == 0) {
return true;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: redundant check

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It does allow us to skip calling getRowPositionInDataRegion, which I thought might be useful.


@Override
public boolean isCompletelyNonNullKey(int row)
public boolean hasNonNullKeyParts(int row, int[] keyParts)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sidenote, we should mention somewhere in Javadoc that compare implementation assumes null == null, therefore this method can be called to filter out those rows.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added.

0
)
);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I was hoping to find a UT test case with is not distinct from sql query with sort merge enabled.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good news, testJoinWithExplicitIsNotDistinctFromCondition is that test case 😄

This test was passing on master because the join was getting switched quietly to broadcast. Now it actually runs as sort-merge, which is why I had to add sortIfSortBased (the results are now in a different order).

@gianm gianm merged commit c96b215 into apache:master Mar 19, 2024
@gianm gianm deleted the smj-indf branch March 19, 2024 19:02
@adarshsanjeev adarshsanjeev added this to the 30.0.0 milestone May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area - Batch Ingestion Area - MSQ For multi stage queries - https://github.com/apache/druid/issues/12262 Area - Querying

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants