Query: "SELECT * FROM [table] ORDER BY id DESC LIMIT 10" AllowLargeResults = true FlattenResults = false table schema: [ { "name": "id", "type": "STRING", "mode": "NULLABLE" }, { "name": "repeated_field_1", "type": "STRING", "mode": "REPEATED" }, { "name": "repeated_field_2", "type": "STRING", "mode": "REPEATED" } ]
查询" SELECT * FROM [table] LIMIT 10"工作得很好。当我添加order by子句时,我收到此错误,即使order by没有提到重复字段。
有没有办法让这项工作?
答案 0 :(得分:2)
ORDER BY
子句会导致BigQuery自动展平查询的输出,导致您的查询尝试生成repeated_field_1和repeated_field_2的叉积。
如果您不关心保留字段的重复性,则可以明确FLATTEN
这两个字段,这将导致您的查询生成原始查询抱怨的交叉产品。< / p>
SELECT *
FROM FLATTEN(FLATTEN([table], repeated_field_1), repeated_field_2)
ORDER BY id DESC
LIMIT 10
除此之外,我对ORDER BY
的查询都没有很好的解决方法,也输出重复的字段。