scarlin-cloudera commented on a change in pull request #970: Hive 23100
URL: https://github.com/apache/hive/pull/970#discussion_r405696349
##########
File path:
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/HiveCalciteUtil.java
##########
@@ -1157,4 +1174,112 @@ public Void visitInputRef(RexInputRef inputRef) {
return inputRefSet;
}
}
+
+ /** Fixes up the type of all {@link RexInputRef}s in an
+ * expression to match differences in nullability.
+ *
+ * <p>Throws if there any greater inconsistencies of type. */
+ public static List<RexNode> fixUp(final RexBuilder rexBuilder,
+ List<RexNode> nodes, final List<RelDataType> fieldTypes) {
+ return new FixNullabilityShuttle(rexBuilder, fieldTypes).apply(nodes);
+ }
+
+ /** Fixes up the type of all {@link RexInputRef}s in an
+ * expression to match differences in nullability.
+ *
+ * <p>Throws if there any greater inconsistencies of type. */
+ public static RexNode fixUp(final RexBuilder rexBuilder,
+ RexNode node, final List<RelDataType> fieldTypes) {
+ return new FixNullabilityShuttle(rexBuilder, fieldTypes).apply(node);
+ }
+
+ /** Shuttle that fixes up an expression to match changes in nullability of
+ * input fields. */
+ public static class FixNullabilityShuttle extends RexShuttle {
+ private final List<RelDataType> typeList;
+ private final RexBuilder rexBuilder;
+
+ public FixNullabilityShuttle(RexBuilder rexBuilder,
+ List<RelDataType> typeList) {
+ this.typeList = typeList;
+ this.rexBuilder = rexBuilder;
+ }
+
+ @Override public RexNode visitInputRef(RexInputRef ref) {
+ final RelDataType rightType = typeList.get(ref.getIndex());
+ final RelDataType refType = ref.getType();
+ if (refType == rightType) {
Review comment:
equals?
----------------------------------------------------------------
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]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]