0

EDIT: Fixed - for ruby use "insert_all" instead of "insertAll" like the api specifies. The api for ruby needs updating.

Im using v 0.6.4 of the google-api-client gem and trying to create a streaming insert, but keep getting the following error:

google_bigquery.rb:233:in undefined method `insertAll' for #<Google::APIClient::Resource:0xcbc974 NAME:tabledata> (NoMethodError)

My code is as follows:

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

Could someone tell me if the insetAll has been created for the google-api-client gem? I have tried 'insert' as that is what table, dataset etc use and get the same error as well.. I can however run tabledata.list perfectly fine.. I've tried digging throught the gem source code and didn't get anywhere with that.

Is the body object that I created correct or do I need to alter it?

Any help is much appreciated.

Thanks in advance and have a great day.

user2989892
  • 63
  • 2
  • 8

1 Answers1

1

Ok. So fixed it and updated the code in the question. For ruby: the method is called "insert_all". Also note that the table & schema must be created BEFORE the insert_all. This id different when compared to the the "jobs.insert" method which will create the table if it doesn't exist

user2989892
  • 63
  • 2
  • 8