Skip to content

[CALCITE-6948] Implement MinusToAntiJoinRule#4298

Merged
mihaibudiu merged 1 commit intoapache:mainfrom
xiedeyantu:to-anti
Apr 14, 2025
Merged

[CALCITE-6948] Implement MinusToAntiJoinRule#4298
mihaibudiu merged 1 commit intoapache:mainfrom
xiedeyantu:to-anti

Conversation

@xiedeyantu
Copy link
Copy Markdown
Member

Please see: CALCITE-6948

@mihaibudiu mihaibudiu added the LGTM-will-merge-soon Overall PR looks OK. Only minor things left. label Apr 10, 2025
@xiedeyantu
Copy link
Copy Markdown
Member Author

@mihaibudiu Hi, this pr has a minor change, please have a look thanks!

relBuilder.isNotDistinctFrom(
rexBuilder.makeInputRef(leftFieldType, i),
rexBuilder.makeInputRef(rightFieldType, i + fieldCount)));
if (!leftFieldType.isNullable() && !rightFieldType.isNullable()) {
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 wonder whether this is enough.
You can join on ROW types, and in this case I wonder whether the check should be done on each field.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I suddenly thought of a question. We need to judge whether it is nullable more precisely, so as to convert is not distinct from to =?

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.

it will work for scalar types as it is; you could check that

Copy link
Copy Markdown
Member Author

@xiedeyantu xiedeyantu Apr 11, 2025

Choose a reason for hiding this comment

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

Will it have any impact if we use is not distinct from uniformly and do not make more complex judgments (return to the logic of the previous version)? Maybe Relbuilder or other rule can reduce is not distinct from.

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.

the previous is correct, but this one can be slightly more efficient.
However, perhaps this kind of rewrite should be in the scope of a different rule, which could perform it everywhere?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

So I change it back?

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.

Personally I think it's cleaner if each optimization is done by a separate transformation rather than each transformation trying to perform many small optimizations by itself.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I agree with you, I will convert the new commit soon.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done!

@sonarqubecloud
Copy link
Copy Markdown

@mihaibudiu
Copy link
Copy Markdown
Contributor

If not one has comments I plan to merge this soon.
@suibianwanwank you have looked at similar stuff recently, if you want to take a peek.


/** Test case for <a href="https://issues.apache.org/jira/browse/CALCITE-6948">[CALCITE-6948]
* Implement IntersectToSemiJoinRule</a>. */
@Test void testMinusToAntiJoinRule() {
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.

maybe you will be able to write a few quidem tests too after we merge #4301

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, I am submitting #4301 to the draft branch now and would like everyone to see if this approach is acceptable. Then I will adjust the implementation method according to everyone's suggestions. The cases written in JdbcTest can all be completed using quidem tests.

@mihaibudiu mihaibudiu merged commit 749a850 into apache:main Apr 14, 2025
53 checks passed
@xiedeyantu xiedeyantu deleted the to-anti branch October 10, 2025 01:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

LGTM-will-merge-soon Overall PR looks OK. Only minor things left.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants