我想在BigQuery中选择表的唯一行,但出现以下错误:“ ARRAY类型的列单位不能在SELECT DISTINCT中使用”。
我的查询是
SELECT DISTINCT * from <table>
表架构
{
"mode": "NULLABLE",
"name": "company_name",
"type": "STRING"
},
{
"mode": "NULLABLE",
"name": "vat_number",
"type": "STRING"
},
{
"fields": [
{
"mode": "NULLABLE",
"name": "name",
"type": "STRING"
}
],
"mode": "REPEATED",
"name": "industry",
"type": "RECORD"
}
如何在BigQuery中选择带有嵌套字段的表的不同行?
答案 0 :(得分:1)
您可以使用ANY_VALUE函数在GROUP BY中选择嵌套字段的值(假设该值在整个组中都是相同的):
SELECT
company_name,
vat_number,
ANY_VALUE(industry) AS industry
FROM
<table>
GROUP BY
company_name,
vat_number