google-bigquery - 如何检查结构的所有字段是否为 NULL?
问题描述
我想检查我的 BigQuery 结构(RECORD
类型,不重复)中的所有字段是否为 NULL。usingstruct_column IS NULL
不起作用,因为false
即使其中的所有字段struct_column
都是 NULL,它也会返回。
解决方案
整个结构为 NULL 在语义上与其所有字段为 NULL 不同,您必须逐个字段检查。
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));
输出:
+------+-------+-------+
| f0_ | f1_ | f2_ |
+------+-------+-------+
| true | false | false |
+------+-------+-------+
推荐阅读
- r - samr 分析:如何解释中值 FDR/90th perc FDR=0.000000?
- java - 检查 OutputStream 是否有损坏的管道
- python - django框架中python中的导入错误
- dialogflow-es - Actions on Google 将拼写数字转换为字符串
- unit-testing - 在 python 中使用鼻子进行单元测试
- r - 从 ONS 下载县 Shapefile
- java - MainActivity$2 符号出错但实际上与活动无关?
- python - 具有列表理解的圆形列表值,包括无
- bash - 退出tail -f后如何继续shell文件?
- git - 摆脱 git 不需要的合并分支?