Google Bigquery中的REPEATED字段是什么意思? [英] What does REPEATED field in Google Bigquery mean?
问题描述
请查看我对以下示例中REPEATED字段的理解:
{
title:History字母,
作者:[
{
name:Larry
},
]
}
这个JSON有schema:
<$ c
$ name b
$ b $ :author,
type:RECORD,
fields:[
{
name:name,
type :STRING
}
]
}
]
但是下面的JSON
{
title:Alphabet of History,
author:[Larry,Steve,Eric]
}
有schema:
[
{
name:title,
type:STRING
},
name:author,
type:STRING,
mode:REPEATED
}
]
是否正确?
nb:我尝试了解文档,但找不到任何解释这个。
关闭。在第一个例子中, author
是一个对象数组,它对应于BQ中的重复记录。所以这个模式是:
[
{
name:title,
type:STRING
},
{
name:author,
type:RECORD,
mode :REPEATED,< ---注意!
字段:[
{
name:name,
type:STRING
}
] $ b $您的第二个数据/模式对看起来不错(但请注意,总体来说, schema是一个数组,不是一个对象,它需要元素之间的逗号)。
这里有一些关于嵌套和重复字段的讨论:
https://cloud.google.com/bigquery/docs/data?hl=en#nested
这里还有一些示例JSON数据对象:
https://cloud.google.com/bigquery/preparing-data-for-bigquery#dataformats
但我同意我们不能很好地解释这些对象如何映射到BQ模式。对不起!
Please check my understanding of REPEATED field in the following examples:
{
"title": "History of Alphabet",
"author": [
{
"name": "Larry"
},
]
}
This JSON has schema:
[
{
"name": "title",
"type": "STRING"
},
{
"name": "author",
"type": "RECORD",
"fields": [
{
"name": "name",
"type": "STRING"
}
]
}
]
But the following JSON
{
"title": "History of Alphabet",
"author": ["Larry", "Steve", "Eric"]
}
has schema:
[
{
"name": "title",
"type": "STRING"
},
{
"name": "author",
"type": "STRING",
"mode": "REPEATED"
}
]
Is this correct?
nb: I tried to go through the documentation, but can't find any explanation about this.
解决方案 Close. In your first example, author
is an array of objects, which corresponds to a repeated record in BQ. So the schema would be:
[
{
"name": "title",
"type": "STRING"
},
{
"name": "author",
"type": "RECORD",
"mode": "REPEATED", <--- NOTE!
"fields": [
{
"name": "name",
"type": "STRING"
}
]
}
]
Your second data/schema pair looks good (but note that the overall schema is an array, not an object, and it needs commas between elements).
There is some discussion of nested and repeated fields here:
https://cloud.google.com/bigquery/docs/data?hl=en#nested
There are also some sample JSON data objects here:
https://cloud.google.com/bigquery/preparing-data-for-bigquery#dataformats
But I agree we don't do a good job of explaining how those objects map to BQ schemas. Sorry about that!
这篇关于Google Bigquery中的REPEATED字段是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!