-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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 logging of plan optimizer #21226
Conversation
2542e12
to
2e67c57
Compare
Thanks for fixing these! |
...src/main/java/com/facebook/presto/sql/planner/optimizations/RandomizeNullKeyInOuterJoin.java
Outdated
Show resolved
Hide resolved
{ | ||
PlanWithProperties result = new Rewriter(idAllocator, variableAllocator, session, partitioningProviderManager).accept(plan, PreferredProperties.any()); | ||
return result.getNode(); | ||
boolean optimizerTriggered = PlanNodeSearcher.searchFrom(result.getNode()).where(node -> node instanceof ExchangeNode && ((ExchangeNode) node).getScope().isRemote()).findFirst().isPresent(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are we sure that this optimizer added the exchange node and it wasn't there before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we only have this optimizer to add remote exchange node.
{ | ||
if (optimizer instanceof IterativeOptimizer) { | ||
// iterative optimizers do their own recording of what rules got triggered | ||
return; | ||
} | ||
|
||
String optimizerName = optimizer.getClass().getSimpleName(); | ||
boolean isTriggered = (oldNode != newNode); | ||
boolean isTriggered = planOptimizerResult.isOptimizerTriggered(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of comparing plan node, now the optimizer returns whether the plan is changed or not.
Change the result type of PlanOptimizer, so that it not only returns the new plan node, but also returns whether the optimizer is triggered or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will all new optimizers will have to implement isOptimizerTriggered method. So all spi optimizers and our internal optimizers api might change. Please add that in release notes
Description
Change the result type of PlanOptimizer, so that it not only returns the new plan node, but also returns whether the optimizer is triggered or not.
Motivation and Context
Currently, the logging of PlanOptimizer is to compare the old and new plan root with the equal operator. However, this leads to false positives, where any non meaningful changes (for example reorder of outputs etc) will show as optimizer triggered. It also relies on proper equal() override for all data structures in query plans.
In this PR, I change the PlanOptimizer to explicitly return whether an optimizer is triggered or not. I've implemented them for all existing plan optimizers.
Impact
Fix logging of optimizers, and eliminate false positives.
Test Plan
Existing unit tests.
Contributor checklist
Release Notes
Please follow release notes guidelines and fill in the release notes below.