Amazon Redshift 中 "x is true" 的布尔值评估不一致
Inconsistent boolean evaluation with "x is true" in Amazon Redshift
使用 Amazon Redshift。我有一个具有 3 个不同值的布尔字段 - true、false 和 null。
当我尝试计算 (x is true)
时,我收到一条 Not implemented
错误消息。不过,尝试评估 (x = true)
效果很好。
dataeng=# with bool_vals as (select distinct val::boolean as x from my_table) select * from bool_vals;
x
---
f
t
(3 rows)
dataeng=# with bool_vals as (select distinct val::boolean as x from my_table) select *, (x is null) from bool_vals;
x | ?column?
---+----------
f | f
t | f
| t
(3 rows)
dataeng=# with bool_vals as (select distinct val::boolean as x from my_table) select *, (x is true) from bool_vals;
ERROR: Not implemented
DETAIL:
-----------------------------------------------
error: Not implemented
code: 1001
context: 'false' - project naming - 330
query: 114596
location: cg_main.cpp:1265
process: padbmaster [pid=7556]
-----------------------------------------------
dataeng=# with bool_vals as (select distinct val::boolean as x from my_table) select *, (x = true) from bool_vals;
x | ?column?
---+----------
t | t
f | f
|
(3 rows)
奇怪的是,我无法使用简单的示例案例重现它:
dataeng=# with bools as (select true as x union select false union select null) select *, (x is true) from bools;
x | ?column?
---+----------
f | f
t | t
| f
(3 rows)
我同意使用 =
作为计算布尔逻辑的运算符,但这种行为不一致似乎很奇怪,我想弄清楚这里发生了什么。
在 Redshift 中,查询的 SELECT
部分不支持 IS {TRUE|FALSE|UNKNOWN}
语法。 仅 支持作为 WHERE
谓词。
我们在文档中添加了一条注释和一个新示例来阐明这一点。 https://docs.aws.amazon.com/redshift/latest/dg/r_Boolean_type.html
使用 Amazon Redshift。我有一个具有 3 个不同值的布尔字段 - true、false 和 null。
当我尝试计算 (x is true)
时,我收到一条 Not implemented
错误消息。不过,尝试评估 (x = true)
效果很好。
dataeng=# with bool_vals as (select distinct val::boolean as x from my_table) select * from bool_vals;
x
---
f
t
(3 rows)
dataeng=# with bool_vals as (select distinct val::boolean as x from my_table) select *, (x is null) from bool_vals;
x | ?column?
---+----------
f | f
t | f
| t
(3 rows)
dataeng=# with bool_vals as (select distinct val::boolean as x from my_table) select *, (x is true) from bool_vals;
ERROR: Not implemented
DETAIL:
-----------------------------------------------
error: Not implemented
code: 1001
context: 'false' - project naming - 330
query: 114596
location: cg_main.cpp:1265
process: padbmaster [pid=7556]
-----------------------------------------------
dataeng=# with bool_vals as (select distinct val::boolean as x from my_table) select *, (x = true) from bool_vals;
x | ?column?
---+----------
t | t
f | f
|
(3 rows)
奇怪的是,我无法使用简单的示例案例重现它:
dataeng=# with bools as (select true as x union select false union select null) select *, (x is true) from bools;
x | ?column?
---+----------
f | f
t | t
| f
(3 rows)
我同意使用 =
作为计算布尔逻辑的运算符,但这种行为不一致似乎很奇怪,我想弄清楚这里发生了什么。
在 Redshift 中,查询的 SELECT
部分不支持 IS {TRUE|FALSE|UNKNOWN}
语法。 仅 支持作为 WHERE
谓词。
我们在文档中添加了一条注释和一个新示例来阐明这一点。 https://docs.aws.amazon.com/redshift/latest/dg/r_Boolean_type.html