如何在bigquery中过滤行,其中嵌套的重复字段包含特定值?

时间:2017-07-28 12:17:35

标签: google-bigquery

让我们假设嵌套的重复字段是Experience.Company,Experience.Months。 现在,如果体验记录包含,那么" GE"在Experience.Company中,我想跳过整个记录。

我试过的查询是这样的:

select name, location from table_name where Experience.Company != "GE".

这显然不起作用,因为我得到了其他值的记录。

我尝试了OMIT IF,结果相同。

我还能尝试其他什么?

2 个答案:

答案 0 :(得分:2)

以下是BigQuery Standard SQL

  
#standardSQL
WITH `table_name` AS (
  SELECT 1 AS id, 'John' AS Name, 'LA' AS Location, [STRUCT<Company STRING, Months INT64>('Google', 24), ('Apple', 36)] AS Experience UNION ALL
  SELECT 2, 'Nick', 'SF', [STRUCT<Company STRING, Months INT64>('GE', 12), ('Microsoft', 48)] AS Experience UNION ALL
  SELECT 3, 'Mike', 'LV', [STRUCT<Company STRING, Months INT64>('Facebook', 24), ('Cloudera', 36)] AS Experience 
)
SELECT name, location FROM `table_name`
WHERE NOT EXISTS (SELECT 1 FROM UNNEST(Experience) WHERE Company = 'GE')

答案 1 :(得分:0)

我指的是

BigQuery REPEATED field contains

所以查询如下:

Select column1, column2, 
sum(experience.company contains "GE") within record as matches 
from [mytable] 
having matches = 0