kasakrisz commented on code in PR #4253:
URL: https://github.com/apache/hive/pull/4253#discussion_r1176138739
##########
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveRemoveEmptySingleRules.java:
##########
@@ -192,6 +178,79 @@ public interface JoinRightEmptyRuleConfig extends
PruneEmptyRule.Config {
}
}
+ private static RelNode padWithNulls(RelBuilder builder, RelNode input,
RelDataType resultType,
+ boolean leftPadding) {
+ int padding = resultType.getFieldCount() -
input.getRowType().getFieldCount();
+ List<RexNode> nullLiterals = Collections.nCopies(padding,
builder.literal(null));
+ builder.push(input);
+ if (leftPadding) {
+ builder.project(concat(nullLiterals, builder.fields()));
+ } else {
+ builder.project(concat(builder.fields(), nullLiterals));
+ }
+ return builder.convert(resultType, true).build();
+ }
+
+ public static final RelOptRule CORRELATE_RIGHT_INSTANCE =
RelRule.Config.EMPTY
+ .withOperandSupplier(b0 ->
+ b0.operand(Correlate.class).inputs(
+ b1 -> b1.operand(RelNode.class).anyInputs(),
+ b2 ->
b2.operand(Values.class).predicate(Values::isEmpty).noInputs()))
+ .withDescription("PruneEmptyCorrelate(right)")
+ .withRelBuilderFactory(HiveRelFactories.HIVE_BUILDER)
+ .as(CorrelateEmptyRuleConfig.class)
+ .toRule();
+ public static final RelOptRule CORRELATE_LEFT_INSTANCE = RelRule.Config.EMPTY
+ .withOperandSupplier(b0 ->
+ b0.operand(Correlate.class).inputs(
+ b1 ->
b1.operand(Values.class).predicate(Values::isEmpty).noInputs(),
+ b2 -> b2.operand(RelNode.class).anyInputs()))
+ .withDescription("PruneEmptyCorrelate(left)")
+ .withRelBuilderFactory(HiveRelFactories.HIVE_BUILDER)
+ .as(CorrelateEmptyRuleConfig.class)
+ .toRule();
+
+ /** Configuration for rule that prunes a correlate if one of its inputs is
empty. */
+ public interface CorrelateEmptyRuleConfig extends PruneEmptyRule.Config {
Review Comment:
nit: should the implementation of this class go into two separate classes
since there is no common parts of handling left and right empty inputs?
##########
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveRemoveEmptySingleRules.java:
##########
@@ -192,6 +178,79 @@ public interface JoinRightEmptyRuleConfig extends
PruneEmptyRule.Config {
}
}
+ private static RelNode padWithNulls(RelBuilder builder, RelNode input,
RelDataType resultType,
+ boolean leftPadding) {
Review Comment:
nit: you can get rid of the flag argument `leftPadding` by creating two
methods each of them responsible only for one type of padding:
```
leftPadWithNulls(RelBuilder builder, RelNode input, RelDataType resultType)
rightPadWithNulls(RelBuilder builder, RelNode input, RelDataType resultType)
```
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]