如何检查结构的所有字段是否均为NULL?

时间:2019-11-20 17:04:51

标签: google-bigquery

我想检查BigQuery结构(RECORD类型,不重复)中的所有字段是否均为NULL。使用struct_column IS NULL不起作用,因为即使false中的所有字段均为NULL,它也会返回struct_column

1 个答案:

答案 0 :(得分:0)

整个结构为NULL的语义与所有字段均为NULL的语义不同,您必须逐字段检查。

figure

输出:

create temp function all_fields_is_null(s struct<x int64, y int64>) 
as (s.x is null and s.y is null);

select 
 all_fields_is_null((null, null)),
 all_fields_is_null((1, null)),
 all_fields_is_null((1, 1));