[
https://issues.apache.org/jira/browse/CALCITE-1531?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15726680#comment-15726680
]
Julian Hyde commented on CALCITE-1531:
--------------------------------------
In the SQL standard, NULL is not a literal. It is a "contextually typed value
specification", like DEFAULT:
{noformat}
6.5 <contextually typed value specification>
Function
Specify a value whose data type is to be inferred from its context.
Format
<contextually typed value specification> ::=
<implicitly typed value specification>
| <default specification>
<implicitly typed value specification> ::=
<null specification>
| <empty specification>
<null specification> ::=
NULL
<empty specification> ::=
ARRAY <left bracket or trigraph> <right bracket or trigraph>
| MULTISET <left bracket or trigraph> <right bracket or trigraph>
<default specification> ::=
DEFAULT
Syntax Rules
...
2) The declared type DT of a <null specification> NS is determined by the
context in which NS appears. NS is effectively replaced by CAST ( NS AS DT ).
{noformat}
> SqlValidatorException when boolean operators are used with NULL
> ---------------------------------------------------------------
>
> Key: CALCITE-1531
> URL: https://issues.apache.org/jira/browse/CALCITE-1531
> Project: Calcite
> Issue Type: Bug
> Reporter: Serhii Harnyk
> Assignee: Julian Hyde
>
> SqlValidatorException when we use boolean AND, OR operators with null.
> {noformat}
> 0: jdbc:calcite:localhost> SELECT (CASE WHEN true or null then 1 else 0 end)
> from (VALUES(1));
> 2016-12-06 17:12:47,622 [main] ERROR -
> org.apache.calcite.sql.validate.SqlValidatorException: Illegal use of 'NULL'
> 2016-12-06 17:12:47,623 [main] ERROR -
> org.apache.calcite.runtime.CalciteContextException: From line 1, column 27 to
> line 1, column 30: Illegal use of 'NULL'
> Error: Error while executing SQL "SELECT (CASE WHEN true or null then 1 else
> 0 end) from (VALUES(1))": From line 1, column 27 to line 1, column 30:
> Illegal use of 'NULL' (state=,code=0)
> {noformat}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)