asolimando commented on code in PR #2916:
URL: https://github.com/apache/calcite/pull/2916#discussion_r976611160
##########
core/src/main/java/org/apache/calcite/rel/rules/PruneEmptyRules.java:
##########
@@ -491,6 +513,29 @@ public interface JoinLeftEmptyRuleConfig extends
PruneEmptyRule.Config {
}
}
+ private static void addNullLiterals(RexBuilder rexBuilder, Values empty,
+ List<RexNode> projectFields, List<String> newColumnNames) {
+ for (int i = 0; i < empty.getRowType().getFieldList().size(); ++i) {
+ RelDataTypeField relDataTypeField =
empty.getRowType().getFieldList().get(i);
+ RexNode nullLiteral =
rexBuilder.makeNullLiteral(relDataTypeField.getType());
+ projectFields.add(nullLiteral);
+ newColumnNames.add(empty.getRowType().getFieldList().get(i).getName());
+ }
+ }
+
+ public static void copyProjects(RexBuilder rexBuilder, RelDataType inRowType,
+ RelDataType castRowType, int castRowTypeOffset,
+ List<RexNode> outProjects, List<String> outProjectNames) {
+ for (int i = 0; i < inRowType.getFieldCount(); ++i) {
+ RelDataTypeField relDataTypeField = inRowType.getFieldList().get(i);
+ RexInputRef inputRef =
rexBuilder.makeInputRef(relDataTypeField.getType(), i);
+ RexNode cast = rexBuilder.makeCast(
+ castRowType.getFieldList().get(castRowTypeOffset + i).getType(),
inputRef);
+ outProjects.add(cast);
+ outProjectNames.add(relDataTypeField.getName());
+ }
+ }
+
Review Comment:
As highlighted in the corresponding Hive PR, since those two methods are
used by both rules, it would be better to move them either before them, or
after them, rather than having them in between the rules as of now.
--
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]