[
https://issues.apache.org/jira/browse/FLINK-18164?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Benchao Li updated FLINK-18164:
-------------------------------
Description:
In ISO SQL standard, boolean is three-value type, including {{true}},
{{false}}, {{unknown.}}
And in Flink SQL, we also go with the SQL standard, and the {{unknown}} will be
{{null}}. For example:
{code:SQL}
SELECT null <> null -- null
SELECT null <> 'hello' -- null
SELECT null = null -- null
SELECT null <> 'hello' -- null
{code}
In {{where}} clause, we evaluate `null` boolean to `false` by default. For
example:
{code:SQL}
... WHERE null <> null -- evaluate to false, there is no output
... null <> 'hello' -- evaluate to false, there is no output
SELECT IF(null = null, 0, 1) -- 1
SELECT IF(null <> 'hello', 0, 1) -- 1
{code}
To make {{null}} comparable to others, use can use {{IS [NOT] DISTINCT FROM}}.
For example:
{code:SQL}
SELECT null IS NOT DISTINCT FROM null -- true
SELECT null IS DISTINCT FROM 'hello' -- true
{code}
~~~~~~~~original description~~~~~~~~
Currently, if we compare null with other literals, the result will always be
false.
It's because the code gen always gives a default value (false) for the result.
And I think it's a bug if `null <> 'str'` is false.
It's reported from user-zh:
[http://apache-flink.147419.n8.nabble.com/flink-sql-null-false-td3640.html]
CC [~jark] [~ykt836]
was:
In IOS SQL standard, boolean is three-value type, including {{true}},
{{false}}, {{unknown}}
~~~~~~~~original description~~~~~~~~
Currently, if we compare null with other literals, the result will always be
false.
It's because the code gen always gives a default value (false) for the result.
And I think it's a bug if `null <> 'str'` is false.
It's reported from user-zh:
http://apache-flink.147419.n8.nabble.com/flink-sql-null-false-td3640.html
CC [~jark] [~ykt836]
> null <> 'str' should be true
> ----------------------------
>
> Key: FLINK-18164
> URL: https://issues.apache.org/jira/browse/FLINK-18164
> Project: Flink
> Issue Type: Bug
> Components: Table SQL / API
> Reporter: Benchao Li
> Priority: Major
>
> In ISO SQL standard, boolean is three-value type, including {{true}},
> {{false}}, {{unknown.}}
> And in Flink SQL, we also go with the SQL standard, and the {{unknown}} will
> be {{null}}. For example:
>
> {code:SQL}
> SELECT null <> null -- null
> SELECT null <> 'hello' -- null
> SELECT null = null -- null
> SELECT null <> 'hello' -- null
> {code}
>
> In {{where}} clause, we evaluate `null` boolean to `false` by default. For
> example:
> {code:SQL}
> ... WHERE null <> null -- evaluate to false, there is no output
> ... null <> 'hello' -- evaluate to false, there is no output
> SELECT IF(null = null, 0, 1) -- 1
> SELECT IF(null <> 'hello', 0, 1) -- 1
> {code}
> To make {{null}} comparable to others, use can use {{IS [NOT] DISTINCT
> FROM}}. For example:
> {code:SQL}
> SELECT null IS NOT DISTINCT FROM null -- true
> SELECT null IS DISTINCT FROM 'hello' -- true
> {code}
>
> ~~~~~~~~original description~~~~~~~~
> Currently, if we compare null with other literals, the result will always be
> false.
> It's because the code gen always gives a default value (false) for the
> result. And I think it's a bug if `null <> 'str'` is false.
> It's reported from user-zh:
> [http://apache-flink.147419.n8.nabble.com/flink-sql-null-false-td3640.html]
> CC [~jark] [~ykt836]
--
This message was sent by Atlassian Jira
(v8.3.4#803005)