asolimando commented on code in PR #3264:
URL: https://github.com/apache/calcite/pull/3264#discussion_r1229976973
##########
core/src/main/java/org/apache/calcite/rel/rules/ProjectJoinRemoveRule.java:
##########
@@ -78,40 +86,56 @@ public ProjectJoinRemoveRule(
final Project project = call.rel(0);
final Join join = call.rel(1);
final boolean isLeftJoin = join.getJoinType() == JoinRelType.LEFT;
- int lower = isLeftJoin
- ? join.getLeft().getRowType().getFieldCount() : 0;
- int upper = isLeftJoin
- ? join.getRowType().getFieldCount()
- : join.getLeft().getRowType().getFieldCount();
-
- // Check whether the project uses columns whose index is between
- // lower(included) and upper(excluded).
- for (RexNode expr: project.getProjects()) {
- if (RelOptUtil.InputFinder.bits(expr).asList().stream().anyMatch(
- i -> i >= lower && i < upper)) {
- return;
- }
- }
+ final boolean isRightJoin = join.getJoinType() == JoinRelType.RIGHT;
+ final boolean isInnerJoin = join.getJoinType() == JoinRelType.INNER;
- final List<Integer> leftKeys = new ArrayList<>();
- final List<Integer> rightKeys = new ArrayList<>();
- RelOptUtil.splitJoinCondition(join.getLeft(), join.getRight(),
- join.getCondition(), leftKeys, rightKeys,
- new ArrayList<>());
+ // Check project range
+ ImmutableBitSet projectBits =
RelOptUtil.InputFinder.bits(project.getProjects(), null);
+ boolean onlyUseLeft = projectBits.asList().stream()
+ .allMatch(i -> i >= 0 && i <
join.getLeft().getRowType().getFieldCount());
Review Comment:
Please extract the common expressions like
`join.getLeft().getRowType().getFieldCount()`, the lambda is already long enough
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]