编辑:已修复 - 对于 ruby,使用“insert_all”而不是 api 指定的“insertAll”。ruby 的 api 需要更新。
我正在使用 google-api-client gem 的 v 0.6.4 并尝试创建流式插入,但不断收到以下错误:
google_bigquery.rb:233:in undefined method `insertAll' for #<Google::APIClient::Resource:0xcbc974 NAME:tabledata> (NoMethodError)
我的代码如下:
def streaming_insert_data_in_table(table, dataset=DATASET)
body = {"rows"=>[
{"json"=> {"person_id"=>1, "name"=>"john"}},
{"json"=> {"person_id"=>2, "name"=>"doe"}},
]}
result = @client.execute(
:api_method=> @bigquery.tabledata.insert_all,
:parameters=> {
:projectId=> @project_id.to_s,
:datasetId=> dataset,
:tableId=>table},
:body_object=>body,
)
puts result.body
end
有人可以告诉我是否为 google-api-client gem 创建了 insetAll 吗?我已经尝试过“插入”,因为那是表、数据集等使用的并且也得到了相同的错误。但是我可以完美地运行 tabledata.list。我尝试挖掘 gem 源代码并没有得到任何地方。
我创建的主体对象是正确的还是需要更改它?
任何帮助深表感谢。
提前致谢,祝您有美好的一天。