soumyakanti3578 commented on code in PR #3849:
URL: https://github.com/apache/calcite/pull/3849#discussion_r1685038515


##########
core/src/main/java/org/apache/calcite/rel/core/Join.java:
##########
@@ -100,6 +100,8 @@ protected Join(
       JoinRelType joinType) {
     super(cluster, traitSet, left, right);
     this.condition = Objects.requireNonNull(condition, "condition");
+    assert SqlTypeName.BOOLEAN == condition.getType().getSqlTypeName()
+        : "condition should be of BOOLEAN type, but was " + 
condition.getType();

Review Comment:
   For `Join`, I tried adding `assert isValid` in the constructor, but 
`CheckerFramework` throws an error:
   ```
   > Task :core:compileJava
   
/home/runner/work/calcite/calcite/core/src/main/java/org/apache/calcite/rel/core/Join.java:107:
 error: [method.invocation.invalid] call to 
isValid(org.apache.calcite.util.Litmus,@org.checkerframework.checker.nullness.qual.Nullable
 org.apache.calcite.rel.RelNode.Context) not allowed on the given receiver.
       assert isValid(Litmus.THROW, null);
                     ^
     found   : @UnderInitialization(org.apache.calcite.rel.core.Join.class) 
@NonNull Join
     required: @Initialized @NonNull Join
   ```
   
   It looks like we can't call it from the constructor without changing some 
config? Or it may be simpler to assert that the condition type is boolean in 
the constructor - just for Join.
   
   I encountered another issue with calling `isValid` from the constructor. 
During `LogicalJoin` instantiation, it calls super and tries to init `Join` and 
then it goes through `isValid` -> `getRowType` -> `deriveRowType` -> 
`getSystemFieldList`. But `LogicalJoin#getSystemFieldList` simply returns 
`systemFieldList` and its value is `null` because the object is still 
initializing and unfortunately `super` has to be the first call in a 
constructor (for now). Finally we get an error because of the `requireNonNull` 
check on `systemFieldList` in `SqlValidatorUtil#deriveJoinRowType`.



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