liyafan82 commented on a change in pull request #2079:
URL: https://github.com/apache/calcite/pull/2079#discussion_r460637726
##########
File path: core/src/main/java/org/apache/calcite/rel/rules/JoinCommuteRule.java
##########
@@ -59,39 +61,62 @@
@Deprecated // to be removed before 1.25
public static final JoinCommuteRule SWAP_OUTER =
CoreRules.JOIN_COMMUTE_OUTER;
+ /**
+ * This is just a sample implementation, with little practical value.
+ */
+ private static final BiPredicate<RelNode, RelNode>
DEFAULT_JOIN_CHILDREN_PREDICATE =
+ (left, right) -> left.getId() < right.getId();
+
private final boolean swapOuter;
+ private final BiPredicate<RelNode, RelNode> joinChildrenPredicate;
+
//~ Constructors -----------------------------------------------------------
/**
* Creates a JoinCommuteRule.
+ * @param clazz class for the join.
+ * @param relBuilderFactory RelNode build factory.
+ * @param swapOuter whether outer joins are supported.
+ * @param joinChildrenPredicate a predicate for the left and right children
of the join.
+ * It checks if it is of value to swap the left and right
child of the join,
+ * so the swap should happen only if the predicate yields
true.The
+ * predicate must form a partial order. That means for
different a and b,
+ * if pred(a, b) = true, then we must have pred(b, a) = false;
and vice versa.
+ * Otherwise, unexpected behaviors may occur, including endless
+ * firing of the rule.
*/
public JoinCommuteRule(Class<? extends Join> clazz,
- RelBuilderFactory relBuilderFactory, boolean swapOuter) {
+ RelBuilderFactory relBuilderFactory, boolean
swapOuter,
+ BiPredicate<RelNode, RelNode> joinChildrenPredicate) {
Review comment:
Sounds reasonable. Argument removed. Thanks.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]