考虑以下BigQuery查询:
SELECT
tn.object AS object_alias,
tn.attribute1 AS attribute1_alias,
tn.attribute2 AS attribute2_alias,
tn.score AS score_alias,
ROW_NUMBER() OVER (PARTITION BY attribute1_alias, attribute2_alias ORDER BY score_alias DESC) AS row_num_alias
FROM
[datasetName.tableName] tn
HAVING # also causes error when using WHERE
row_num_alias <= 20
Run Code Online (Sandbox Code Playgroud)
在此查询中,对子句中的row_num_alias字段的引用HAVING导致以下错误:Field 'row_num_alias' not found.使用HAVING子句替换子句时出现相同的错误WHERE,并且似乎所有窗口函数都抛出此错误.
这是BigQuery中的错误吗?或者我的查询中是否有其他错误?
可能相关:
一种解决方法是将其转换为子查询并将WHERE子句移到子查询之外(见下文),但这看起来很麻烦(并且希望不是必需的).
SELECT
object_alias,
attribute1_alias,
attribute2_alias,
score_alias,
row_num_alias
FROM
(SELECT
tn.object AS object_alias,
tn.attribute1 AS attribute1_alias,
tn.attribute2 AS attribute2_alias, …Run Code Online (Sandbox Code Playgroud) 我正在尝试将深度/不规则嵌套的列表/JSON 对象展平到 R 中的数据帧。
键名是一致的,但嵌套元素的数量从一个元素到另一个元素不同。
我尝试使用jsonlite和tidyr::unnest函数来展平列表,但tidyr::unnest无法取消嵌套包含多个新列的列表列。我也试过使用包中的map函数purrr,但什么也做不了。
下面是 JSON 数据的一个子集,本文末尾包含一个列表对象。
[
{
"name": ["Hillary Clinton"],
"type": ["PERSON"],
"metadata": {
"mid": ["/m/0d06m5"],
"wikipedia_url": ["http://en.wikipedia.org/wiki/Hillary_Clinton"]
},
"salience": [0.2883],
"mentions": [
{
"text": {
"content": ["Clinton"],
"beginOffset": [132]
},
"type": ["PROPER"]
},
{
"text": {
"content": ["Mrs."],
"beginOffset": [127]
},
"type": ["COMMON"]
},
{
"text": {
"content": ["Clinton"],
"beginOffset": [403]
},
"type": ["PROPER"]
},
{
"text": {
"content": ["Mrs."],
"beginOffset": [398]
},
"type": ["COMMON"] …Run Code Online (Sandbox Code Playgroud)