简体   繁体   English

在 BigQuery 中声明数组常量

[英]Declare array constant in BigQuery

I am trying to refactor a SQL query and current query is我正在尝试重构 SQL 查询,当前查询是

WITH first_result AS (
    select table.a,table.b,table.c from table where table.a NOT IN 
    ('x', 'y', 'z',.......1000 more entries)),
second_result AS (....),
SELECT * FROM second_result

How do I separate the ['x', 'y', 'z',.......1000 more entries] into a constant?我如何将['x', 'y', 'z',.......1000 more entries]分成一个常量? I want to make the query more readable我想让查询更具可读性

The original question was about fixing below query -最初的问题是关于修复以下查询 -

with first_result as (
    select table.a,table.b,table.c from table where table.a not in 
    ['x', 'y', 'z']),
second_result as (....),
select * from second_result

With the answer有了答案

You should use WHERE a NOT IN UNNEST(['x', 'y', 'z']) as in below example (BigQuery Standard SQL)您应该使用WHERE a NOT IN UNNEST(['x', 'y', 'z'])如下例(BigQuery Standard SQL)

with first_result as (
    select table.a,table.b,table.c from table where table.a not in 
    UNNEST(['x', 'y', 'z'])  ),
second_result as (....),
select * from second_result

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM