You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "pengzhiwei (JIRA)" <ji...@apache.org> on 2019/04/08 11:41:00 UTC
[jira] [Comment Edited] (CALCITE-2921) nullif(null,y) throws
exception in verification
[ https://issues.apache.org/jira/browse/CALCITE-2921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16804546#comment-16804546 ]
pengzhiwei edited comment on CALCITE-2921 at 4/8/19 11:40 AM:
--------------------------------------------------------------
Hi [~julianhyde], the pr has been updated, here is the mainly change list:
* Forbid to return "NULL" type for SqlOperator. As it may cause uncertain semantics.For example, "Not(null) + 1" can pass the validate, if the "Not(null)"'s return type is "NULL". I have added a default type for most operator which may return "NULL" type.
* add "allowNakedNull()" in SqlConformance.
* fix other issue you mentioned in last review.
Please have a look again,Thanks!
was (Author: pzw2018):
Hi [~julianhyde], the pr has been updated, here is the mainly change list:
* The "NULL" return type of SqlOperator is forbidden. As it may cause uncertain semantics.For example, "Not(null) + 1" can pass the validate, if the "Not(null)"'s return type is "NULL". I have added a default type for most operator which may return "NULL" type.
* add "allowNakedNull()" in SqlConformance.
* fix other issue you mentioned in last review.
Please have a look again,Thanks!
> nullif(null,y) throws exception in verification
> ------------------------------------------------
>
> Key: CALCITE-2921
> URL: https://issues.apache.org/jira/browse/CALCITE-2921
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.18.0
> Reporter: pengzhiwei
> Assignee: pengzhiwei
> Priority: Critical
> Labels: pull-request-available
> Fix For: 1.20.0
>
> Time Spent: 10m
> Remaining Estimate: 0h
>
> Currently calcite will translate "nullif(x,y)" to a case-when expression,just like "case when x = y then null else x".So when "x" is null literal,a exception throws out as follow:
> {code:java}
> ELSE clause or at least one THEN clause must be non-NULL
> {code}
> I have test in mysql,"nullif(null,y) works well.So I think we should allow this usage of "nullif".
> There are two ways to fix this issue:
> 1) Skip the check for "foundNotNull" in SqlCaseOperator#checkOperandTypes:
> {code:java}
> if (!foundNotNull) {
> // according to the sql standard we can not have all of the THEN
> // statements and the ELSE returning null
> if (throwOnFailure) {
> throw callBinding.newError(RESOURCE.mustNotNullInElse());
> }
> return false;
> }{code}
> However, as the comment says, we cannot have all of the THEN and ELSE returning null.
> 2) Disable the translation from nullif to case-when and keep "nullif" as it is.
> Any suggestion is welcomed,Thanks!
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)