-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Refactoring join method in PlanMatchPattern in builder pattern #12423
Refactoring join method in PlanMatchPattern in builder pattern #12423
Conversation
Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: Barun Halder.
|
I am raising the PR which is partially complete. I would like to review my approach before making it a too big as there are several places changes need to be done. |
Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: Barun Halder.
|
@raunaqmorarka, @lukasz-stec can you please review the changes? And also help me out about |
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.
It would be good to find a way to avoid adding new JoinParamUtil.JoinParamBuilder
everywhere.
@@ -66,14 +67,15 @@ public void testNonStraddlingJoinExpression() | |||
assertPlan( | |||
"SELECT * FROM orders JOIN lineitem ON orders.orderkey = lineitem.orderkey AND cast(lineitem.linenumber AS varchar) = '2'", | |||
anyTree( | |||
join(INNER, ImmutableList.of(equiJoinClause("ORDERS_OK", "LINEITEM_OK")), | |||
join(new JoinParamUtil.JoinParamBuilder(INNER, |
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.
adding new JoinParamUtil.JoinParamBuilder(
and .build()
everywhere seems verbose.
Could you come up with some solution that avoids that?
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.
Hi @lukasz-stec The only way I am thinking of having a JoinMatcherBuilder
which will have static method with params joinType
& equiCriteria
to create object of JoinMatcher
, and setter for other attributes.
Like below,
join(JoinMatcherBuilder.buildMatcher(joinType, equiCriteria).filter(filter), leftPlanMatchPattern, rightPlanMatchPattern)
But that will require to change JoinMatcher
from immutable to mutable.
Otherwise, avoiding method overloading to use builder pattern will bring code verbosity. Please guide what can be done?
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.
to remove new JoinParamUtil.JoinParamBuilder
you could have a single class, JoinMatcherBuilder
class JoinMatcherBuilder
{
public static JoinMatcherBuilder join(
JoinNode.Type joinType,
List<ExpectedValueProvider<JoinNode.EquiJoinClause>> expectedEquiCriteria,
PlanMatchPattern left,
PlanMatchPattern right) {..}
...
PlanMatchPattern build() {...}
}
That still requires build
for every current PlanMatchPattern.join
method call.
One way to keep it out of tests is to add duplicated method to every method in PlanMatchPattern
that takes PlanMatchPattern as param to instead take PlanMatchPatternBuilder
(new interface) but that seems too much just for joins.
@sopel39 you're the original issue author. Did you have some ideas on what this should look like when you created the ticket?
import static com.google.common.collect.ImmutableList.toImmutableList; | ||
import static io.trino.sql.tree.ComparisonExpression.Operator.EQUAL; | ||
|
||
public class JoinParamUtil |
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 having JoinParamUtil
and JoinParamBuilder
you could have a single JoinMatcherBuilder
that either builds JoinMatcher
or PlanMatchPattern
@barunhalderkolkata we already have a few examples in |
Fixed in #14542 |
Description
Refactoring join method in PlanMatchPattern in builder pattern
Related issues, pull requests, and links
Fixes #5976