julianhyde commented on code in PR #2916:
URL: https://github.com/apache/calcite/pull/2916#discussion_r977290395
##########
core/src/main/java/org/apache/calcite/rel/rules/PruneEmptyRules.java:
##########
@@ -551,17 +529,15 @@ public interface JoinRightEmptyRuleConfig extends
PruneEmptyRule.Config {
// "select * from emp left join dept" is not necessarily empty if
// dept is empty
// join can be removed and take the left branch, all columns come
from dept are null
- List<RexNode> projects = new ArrayList<>(
- left.getRowType().getFieldCount() +
empty.getRowType().getFieldCount());
- List<String> columnNames = new ArrayList<>(
- left.getRowType().getFieldCount() +
empty.getRowType().getFieldCount());
- // left
- copyProjects(
- rexBuilder, left.getRowType(), join.getRowType(), 0, projects,
columnNames);
- // right
- addNullLiterals(rexBuilder, empty, projects, columnNames);
-
- RelNode project = call.builder().push(left).project(projects,
columnNames).build();
+ List<Pair<? extends RexNode, String>> projects =
+ Stream.concat(
+ getProjectStream(left.getRowType(), join.getRowType(), 0,
rexBuilder),
+ getNullLiteralStream(empty,
rexBuilder)).collect(Collectors.toList());
+
+ RelNode project = call.builder()
+ .push(left)
+ .project(Pair.left(projects), Pair.right(projects))
+ .build();
Review Comment:
I believe that the field names are the same before and after. If so, you
don't need to create pairs of (RexNode, String), just RexNode. Which I think
would simplify getProjectStream and getNullLiteralStream.
--
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]