What does REPEATED field in Google Bigquery mean?

前端 未结 1 1453
温柔的废话
温柔的废话 2021-01-01 15:44

Please check my understanding of REPEATED field in the following examples:

{
    \"title\": \"History of Alphabet\",
    \"author\": [
        {
                     


        
相关标签:
1条回答
  • 2021-01-01 16:09

    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!

    0 讨论(0)
提交回复
热议问题