2016-07-26 87 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

相關問題