[英]How to only SELECT rows with non-zero and non-null columns efficiently in Big Query?
I am having a table with large number of columns in Big Query. 我在Big Query中有一个包含大量列的表。
The table has lot of rows with some column values as 0/0.0 and null. 该表有很多行,某些列值为0 / 0.0,并且为null。
For example 例如
Row A B C D E F
1 "abc" 0 null "xyz" 0 0.0
2 "bcd" 1 5 "wed" 4 65.5
I need to select only those rows which have non zero Integer, Float and non NULL values. 我只需要选择那些具有非零Integer,Float和非NULL值的行。 Basically, I need just Row 2 in the above table
基本上,我只需要上表中的第2行
I know I can do this by using this query for each of the columns 我知道我可以通过对每个列使用此查询来做到这一点
SELECT * FROM table WHERE (B IS NOT NULL AND B is !=0) AND
.
.
.
But I have lot of columns and writing query like this for each of the columns would be difficult. 但是我有很多列,很难为每个列编写这样的查询。 Is there any better approach to handle this?
有没有更好的方法来解决这个问题?
Below example for BigQuery Standard SQL 以下是BigQuery标准SQL的示例
#standardSQL
WITH `project.dataset.table` AS (
SELECT "abc" a, 0 b, NULL c, "xyz" d, 0 e, 0.0 f UNION ALL
SELECT "bcd", 1, 5, "wed", 4, 65.5
)
SELECT *
FROM `project.dataset.table` t
WHERE NOT REGEXP_CONTAINS(TO_JSON_STRING(t), r':0[,}]|null[,}]')
with output 带输出
Row a b c d e f
1 bcd 1 5 wed 4 65.5
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.