2015-04-16 34 views
0

我試圖用tabledata.insert_all以當流導入到大的查詢請求沒有行

job_data = { 
    kind: 'bigquery#tableDataInsertAllRequest', 
    rows: [ 
    { json: { column_name: value} } 
    ] 
} 

response = execute(
    api_method: bigquery.tabledata.insert_all, 
    parameters: { 
    projectId: config['project_id'], 
    datasetId: DATASET_ID, 
    tableId: table_id 
    }, 
    body_object: job_data 
) 

以流數據導入大的查詢,但我總是得到以下錯誤消息

Google::APIClient::Request Sending API request post https://www.googleapis.com/bigquery/v2/projects/propane-tribute-90023/datasets/development/tables/api_requests_20150414/insertAll {"User-Agent"=>"My Test App/1.0 google-api-ruby-client/0.8.5 Mac OS X/10.9.5\n (gzip)", "Content-Type"=>"application/json", "Accept-Encoding"=>"gzip", "Authorization"=>"Bearer ya29.VgFYvU2nxGDhWiCdS47XRw0J-7GLenRry0Cd3AA2D1RDzMh5gnf-m85I5GeSr9oNW51OuUb9mdwObg", "Cache-Control"=>"no-store"} 

Decompressing gzip encoded response (155 bytes) 
Decompressed (261 bytes) 
Google::APIClient::Request Result: 400 {"Vary"=>"X-Origin", "Content-Type"=>"application/json; charset=UTF-8", "Date"=>"Wed, 15 Apr 2015 03:14:17 GMT", "Expires"=>"Wed, 15 Apr 2015 03:14:17 GMT", "Cache-Control"=>"private, max-age=0", "X-Content-Type-Options"=>"nosniff", "X-Frame-Options"=>"SAMEORIGIN", "X-XSS-Protection"=>"1; mode=block", "Server"=>"GSE", "Alternate-Protocol"=>"443:quic,p=0.5", "Transfer-Encoding"=>"chunked"} => {"error"=>{"errors"=>[{"domain"=>"global", "reason"=>"invalid", "message"=>"No rows present in the request.", "locationType"=>"other", "location"=>"rows"}], "code"=>400, "message"=>"No rows present in the request."}} 

不任何人都有相同的問題,並知道如何解決它?

謝謝。

+0

這裏還停留? –

+1

它看起來像你粘貼一個JavaScript片段的例子?你能再看看你的問題,並確保它有意義嗎? – Nick

+0

@FelipeHoffa,是的,我仍然在這裏學習,你需要任何額外的信息? – Leo

回答

0

確保您爲表格模式中存在的所有列標題提供適當的值。提供單獨的「json」條目將使用您提供的列數據填充單獨的行。除非已經爲名爲column_name和value的變量賦值,否則需要在json聲明後面的語句中提供這些值。

樣本的Ruby語法的tabledata.insert_all「行」的操作將如下所示:

body = { 
    "rows" =>[ 
     {"json" => { "person_id" => 10, "person_name" => "test"}}, 
     {"json" => { "person_id" => 11, "person_name" => "test2"}} 
    ] 
} 
+1

感謝喬丹,它現在可以工作 – Leo

相關問題