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

[CALCITE-6462] VolcanoPlanner internal valid may throw exception when… #3851

Merged
merged 1 commit into from
Jul 16, 2024

Conversation

NobiGo
Copy link
Contributor

@NobiGo NobiGo commented Jul 10, 2024

… log trace is enabled

@@ -982,11 +982,17 @@ void propagateCostImprovements(RelNode rel) {
if (!relNode.getTraitSet().satisfies(subset.getTraitSet())) {
continue;
}
if (!cost.isLt(subset.bestCost)) {

// Update subset best and best's cost when we find a cheaper rel
Copy link
Contributor

Choose a reason for hiding this comment

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

these two comments do not really seem to describe what the code next to them is doing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the condition when we need to update the best and best's cost.

Copy link
Contributor

Choose a reason for hiding this comment

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

The line commented does not update anything, it just calls continue.
The comment should say the opposite: if the cost is higher, continue.

@NobiGo NobiGo added the LGTM-will-merge-soon Overall PR looks OK. Only minor things left. label Jul 12, 2024
// best's cost is changed

// Update the current best's cost when we find cost is changed
if (relNode == subset.best && cost.equals(subset.bestCost)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

A question, why relNode == subset.best, but the cost is different?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @YiwenWu , This is because RelSet's one of the subset find a cheaper rel's cost, We need to update the parents the best rel and best cost. In theory, this cost will become smaller, But according to the debug info, The SQL I added in the JdbcAdapterTest shows same rel node 's cost sometimes will become bigger. So I update it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe you could add this information in a comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@YiwenWu @mihaibudiu Thanks for the review. I have added the comment, please review it. Thanks.

Copy link
Contributor

Choose a reason for hiding this comment

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

In general I would avoid using "I" in comments.
I am not sure what "the same RelNode's" means here.
Can you make sure that the comment is grammatically correct?
For example, ", We" is not right, but that's not the only problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mihaibudiu Hi, Thanks for your reminder. I update the Java doc. Hopefully, there is no ambiguity now.

Copy link
Contributor

Choose a reason for hiding this comment

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

First, this is not JavaDoc, it's a regular comment.

Please make the entire comment as simple as possible.

I still don't understand what the comment says and how it relates to the code. Please refer in the comment to variables in the code by name. This comparison is for equality, but the comments talks about "smaller". I don't understand how the comment describes the code. No need to make a story about "I" or "we", just say what the code does.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mihaibudiu , To my knowledge, Java documentation and Java annotation are the same as code comments. So maybe as you say comment is more eloquently here. And if we just describe the code code does, I will change the doc to :
The Best RelNode's cost can be changed in propagate progress, as shown by the test {@link JdbcAdapterTest.testVolcanoPlannerInternalValid}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mihaibudiu Hi , I think the comment is good now, So if you think still need to improve, Please submit another PR to improve it. I am ok with this.

Copy link
Member

Choose a reason for hiding this comment

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

@NobiGo I'd be happy to test this PR in detail and then submit a PR modification comment

@NobiGo NobiGo removed the LGTM-will-merge-soon Overall PR looks OK. Only minor things left. label Jul 14, 2024
Copy link
Member

@caicancai caicancai left a comment

Choose a reason for hiding this comment

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

LGTM

@NobiGo NobiGo merged commit 61e9e25 into apache:main Jul 16, 2024
17 of 18 checks passed
@NobiGo NobiGo deleted the CALCITE-6462 branch July 16, 2024 03:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants