mihaibudiu commented on code in PR #4131:
URL: https://github.com/apache/calcite/pull/4131#discussion_r1909670709


##########
core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java:
##########
@@ -3443,12 +3444,32 @@ private RexNode convertUsing(SqlValidatorNamespace 
leftNamespace,
           throw new AssertionError("field " + name + " is not found in "
               + rowType + " with " + nameMatcher);
         }
+
+        fieldTypes.add(field.getType());
         operands.add(
             rexBuilder.makeInputRef(field.getType(),
                 offset + field.getIndex()));
         offset += rowType.getFieldList().size();
       }
-      list.add(rexBuilder.makeCall(SqlStdOperatorTable.EQUALS, operands));
+
+      RelDataType resultType =
+          validator().getTypeCoercion().commonTypeForBinaryComparison(
+              fieldTypes.get(0), fieldTypes.get(1));
+      if (resultType == null) {
+        throw new IllegalArgumentException("Cannot compute compatible row 
type: " + fieldTypes);

Review Comment:
   I guess this exception message is not very good, I will change it.
   What happens here is that the join is done on two fields which cannot be 
compared.
   But I am not sure this exception can ever happen, because at this point the 
program is validated already, so if the fields are not comparable, this point 
should not be reached.



##########
core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java:
##########
@@ -3443,12 +3444,32 @@ private RexNode convertUsing(SqlValidatorNamespace 
leftNamespace,
           throw new AssertionError("field " + name + " is not found in "
               + rowType + " with " + nameMatcher);
         }
+
+        fieldTypes.add(field.getType());

Review Comment:
   This list just contains two fields, one from the left operand of the join 
and one from the right operand.
   The list is created for each pair of fields that are joined on.
   It's not really row type.



-- 
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]

Reply via email to