命令行将json加载到大查询错误中

时间:2018-10-16 14:57:48

标签: json command-line console google-bigquery

我正在尝试从BQ网站(https://cloud.google.com/bigquery/docs/loading-data-cloud-storage-json#example)加载示例JSON文件,但是从控制台运行该错误

我正在运行命令:

bq load --source_format NEWLINE_DELIMITED_JSON --debug testDataSet.tableData ./SeedFile.json ./schema_test.json

但出现错误

Upload complete.
Waiting on bqjob_rxxxxxx_1 ... (0s) Current status: DONE   
BigQuery error in load operation: Error processing job 'test-project-bqjob_rxxxxxx_1': Error while reading data, error message: JSON table
encountered too many errors, giving up. Rows: 1; errors: 1. Please look into the error stream for more details.
Failure details:
- Error while reading data, error message: JSON parsing error in row

任何收到的建议或帮助。

谢谢

该示例取自Google网站。我已经使用该模式预先创建了表

Field name  Type    Mode    Description
id  STRING  NULLABLE    
first_name  STRING  NULLABLE    
last_name   STRING  NULLABLE    
dob DATE    NULLABLE    
addresses   RECORD  REPEATED    
addresses.status    STRING  NULLABLE    
addresses.address   STRING  NULLABLE    
addresses.city  STRING  NULLABLE    
addresses.state STRING  NULLABLE    
addresses.zip   STRING  NULLABLE    
addresses.numberOfYears STRING  NULLABLE

数据文件为

{"id":"1","first_name":"John","last_name":"Doe","dob":"1968-01-22","addresses":[{"status":"current","address":"123 First Avenue","city":"Seattle","state":"WA","zip":"11111","numberOfYears":"1"},{"status":"previous","address":"456 Main Street","city":"Portland","state":"OR","zip":"22222","numberOfYears":"5"}]}
{"id":"2","first_name":"Jane","last_name":"Doe","dob":"1980-10-16","addresses":[{"status":"current","address":"789 Any Avenue","city":"New York","state":"NY","zip":"33333","numberOfYears":"2"},{"status":"previous","address":"321 Main Street","city":"Hoboken","state":"NJ","zip":"44444","numberOfYears":"3"}]}

架构文件为

[{
        "name": "id",
        "type": "STRING",
        "mode": "NULLABLE"
    },
    {
        "name": "first_name",
        "type": "STRING",
        "mode": "NULLABLE"
    },
    {
        "name": "last_name",
        "type": "STRING",
        "mode": "NULLABLE"
    },
    {
        "name": "dob",
        "type": "DATE",
        "mode": "NULLABLE"
    },
    {
        "name": "addresses",
        "type": "RECORD",
        "mode": "REPEATED",
        "fields": [{
                "name": "status",
                "type": "STRING",
                "mode": "NULLABLE"
            },
            {
                "name": "address",
                "type": "STRING",
                "mode": "NULLABLE"
            },
            {
                "name": "city",
                "type": "STRING",
                "mode": "NULLABLE"
            },
            {
                "name": "state",
                "type": "STRING",
                "mode": "NULLABLE"
            },
            {
                "name": "zip",
                "type": "STRING",
                "mode": "NULLABLE"
            },
            {
                "name": "numberOfYears",
                "type": "STRING",
                "mode": "NULLABLE"
            }
        ]
    }
]

0 个答案:

没有答案