BigQuery标准SQL:检查数组是否为null不起作用

aug*_*lec 0 google-bigquery

如果我启动此查询:

with a as (
select cast(null as array<string>) as x union all select ['str1','str2'] as x)
select * from a where x is null
Run Code Online (Sandbox Code Playgroud)

我得到这个结果:

在此输入图像描述

这是我预期的结果.

但如果我首先启动此查询:

 select cast(null as array<string>) as x union all select ['str1', 'str2'] as x
Run Code Online (Sandbox Code Playgroud)

其结果我保存在数据集"tmp"中的表"a"中,然后我启动此查询:

select * from `tmp.a` where x is null
Run Code Online (Sandbox Code Playgroud)

我得到这个结果:

在此输入图像描述

我期望结果与第一个相同.为什么这两个结果有区别?

tom*_*orb 5

解决方法:要在两种情况下获得相同的结果,可以在where子句中使用该函数ARRAY_LENGTH(x)=0.