2016-07-26 86 views
1

当我试图数据上传到BigQuery资料表的BigQuery错误:</p> <pre><code>[{ "name": "temp", "type": "STRING" }] </code></pre> <p>这里是我的文件,我上传:上传数据

这里的表架构不接收所有不良记录:

{"temp" : "0"} 
{"temp1" : "1"} 
{"temp2" : "2"} 
{"temp3" : "3"} 
{"temp4" : "4"} 
{"temp5" : "5"} 
{"temp6" : "6"} 
{"temp7" : "7"} 
{"temp" : "8"} 
{"temp" : "9"} 

这里是上传使错误bq命令:

bq load --source_format=NEWLINE_DELIMITED_JSON --max_bad_records=100 mydataset.mytable ./tmp.json 

我收到:

Upload complete. 
Waiting on bqjob_123.._1 ... (2s) Current status: DONE 
Warnings encountered during job execution: 

JSON parsing error in row starting at position 15 at file: file-00000000. No such field: temp1. 

JSON parsing error in row starting at position 31 at file: file-00000000. No such field: temp2. 

JSON parsing error in row starting at position 47 at file: file-00000000. No such field: temp3. 

JSON parsing error in row starting at position 63 at file: file-00000000. No such field: temp4. 

JSON parsing error in row starting at position 79 at file: file-00000000. No such field: temp5. 

现在,我使用:

bq --format=prettyjson show -j <jobId> 

,这是我得到什么(我复制这里只是相关字段):

{ 
    "configuration": { 
    ... 
     "maxBadRecords": 100 

    } 
    , 
    "statistics": { 
    "load": { 
     "inputFileBytes": "157", 
     "inputFiles": "1", 
     "outputBytes": "9", 
     "outputRows": "3" 
    } 
    }, 
    "status": { 
    "errors": [ 
     { 
     "message": "JSON parsing error in row starting at position 15 at file: file-00000000. No such field: temp1.", 
     "reason": "invalid" 
     }, 
     { 
     "message": "JSON parsing error in row starting at position 31 at file: file-00000000. No such field: temp2.", 
     "reason": "invalid" 
     }, 
     { 
     "message": "JSON parsing error in row starting at position 47 at file: file-00000000. No such field: temp3.", 
     "reason": "invalid" 
     }, 
     { 
     "message": "JSON parsing error in row starting at position 63 at file: file-00000000. No such field: temp4.", 
     "reason": "invalid" 
     }, 
     { 
     "message": "JSON parsing error in row starting at position 79 at file: file-00000000. No such field: temp5.", 
     "reason": "invalid" 
     } 
    ], 
    "state": "DONE" 
    } 
} 

现在时我去我的桌子我实际上有3个新纪录(实际上匹配outputRows : 3场):

{"temp" : "0"} 
{"temp" : "8"} 
{"temp" : "9"} 

现在这些都是我qustions:

  1. ,你看,我有6个不良记录我只接收5人。 - 没有收到temp6。现在我尝试上传更糟糕的记录文件,并始终只收到5.这是一个bigquery的bug?

  2. 假设我的记录较大,并且我上传了许多记录后启用错误,上传后我怎么知道哪些记录是坏记录? - 我需要知道哪些记录没有加载到bigquery中。 我得到的全部是JSON parsing error in row starting at position 15 at file..位置不会告诉我很多。为什么我不能收到记录的号码?或者有没有办法根据职位计算记录编号?

+1

复制并粘贴到记事本++中,然后单击Ctrl + g并设置选项为偏移量,以帮助您找到问题所在的确切行号 –

回答

3
  1. 我们只返回第5个错误,因为我们不想让答复太大。
  2. 正如我在另一个线程中所解释的,BigQuery旨在通过并行处理大文件来快速处理大文件。如果文件是1GB,我们可能会创建数百个工作人员,每个工作人员处理一个文件块。如果一名工作人员正在处理文件的最后10MB并发现一条错误记录,要知道该记录的编号,则需要读取以前的所有990MB文件。因此每个工人只是报告坏记录的开始位置。一些编辑支持在文件中寻找偏移量。在vim中,1000go将移动到位置1000.少于1000P。
+0

因此,如果我有多于5个错误 - 我可以知道哪些记录没有加载到bigquery中吗? – dina

+0

好问题,不幸的是当前的答案是不支持。我同意5有点小,但我们需要一个边界,所以答复不会太大。 –

+0

如果我会收到一个只包含位置(而不是整个错误描述)的数组,它可以解决这个问题,而不会使回复变大。 – dina

相关问题