[ 
https://issues.apache.org/jira/browse/CALCITE-2688?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16693358#comment-16693358
 ] 

Zoltan Haindrich commented on CALCITE-2688:
-------------------------------------------

Note: there were some safeguards agains this in {{RelBuilder}}; but I think 
that {{RexBuilder}} is also public api...and we might even reach type issues 
during development.

The {{SqlOperator}} class has a method which is doing the return type 
resolution - it's [api 
doc|https://github.com/apache/calcite/blob/d32ee5c320938b5c34ce09df2276c9570c27a301/core/src/main/java/org/apache/calcite/sql/SqlOperator.java#L465]
 doesn't state that it might return null; I propose to keep the api contract; 
and throw an exception in case the resolution fails (and move the check from 
RelBuilder there instead).


> Improve diagnosability when return type could not be inferred.
> --------------------------------------------------------------
>
>                 Key: CALCITE-2688
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2688
>             Project: Calcite
>          Issue Type: Improvement
>            Reporter: Zoltan Haindrich
>            Assignee: Zoltan Haindrich
>            Priority: Major
>
> Currently when the return type inferenence fails; a {{null}} is returned; 
> while leads to an NPE very quickly - the resulting Exception is not 
> informative at all.
> {code}
>   @Test(expected = IllegalArgumentException.class)
>   public void checkNoCommonReturnTypeException() {
>     coalesce(vVarchar(1), vInt(2));
>   }
> {code}
> example NPE:
> {code}
> java.lang.NullPointerException
>       at java.util.Objects.requireNonNull(Objects.java:203)
>       at org.apache.calcite.rex.RexCall.<init>(RexCall.java:59)
>       at org.apache.calcite.rex.RexBuilder.makeCall(RexBuilder.java:242)
>       at org.apache.calcite.rex.RexBuilder.makeCall(RexBuilder.java:254)
>       at 
> org.apache.calcite.test.RexProgramBuilderBase.coalesce(RexProgramBuilderBase.java:300)
>       at 
> org.apache.calcite.test.RexProgramTest.checkNoCommonReturnTypeException(RexProgramTest.java:753)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to