[英]Unsupported variable type: STRUCT<INT64>
I've got a query where I need to use a list of strings over and over in a query and would like to declare it once, the only thing is I've only got it working as it is in the second example and would like to not have to UNNEST我有一个查询,我需要在查询中一遍又一遍地使用字符串列表,并且想声明一次,唯一的事情是我只让它像第二个示例中那样工作并且想要不必 UNNEST
DECLARE
list X DEFAULT (
8335, 9776, 11496);
SELECT * FROM `dataset.table` WHERE quantity_sold IN list
X as not sure what type it'd have to be X 因为不确定它必须是什么类型
DECLARE
list ARRAY<INT64> DEFAULT [
8335, 9776, 11496];
SELECT * FROM `dataset.table` WHERE quantity_sold IN UNNEST(list)
this is the "trick" I am usually using in such cases这是我通常在这种情况下使用的“技巧”
with my_variables as (
select [8335, 9776, 11496] list1, ['a', 'b', 'c'] list2
# note: this is just one row CTE
)
select *
from `dataset.table`, my_valiables
where quantity_sold in unnest(list1)
and something_else in unnest(list1)
and yet_another_one in unnest(list2)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.