1

を使用してインポートデータを大きなクエリにストリーミングしようとしていました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."}}

誰かが同じ問題を抱えていて、それを修正する方法を知っていますか?

ありがとう。

4

1 に答える 1

0

テーブルのスキーマにあるすべての列ヘッダーに適切な値を指定していることを確認してください。個別の「json」エントリを指定すると、指定した列データが個々の行に入力されます。column_name および value という名前の変数に値を割り当てていない場合は、json 宣言に続くステートメントでそれらの値を指定する必要があります。

tabledata.insert_all の「行」操作のサンプル Ruby 構文は次のようになります。

body = {
   "rows" =>[ 
      {"json" => { "person_id" => 10, "person_name" => "test"}}, 
      {"json" => { "person_id" => 11, "person_name" => "test2"}} 
   ]
}
于 2015-04-24T19:05:25.507 に答える