0

Im trying to use the streaming insert_all method to insert data to a table using the google-api-client gem in ruby.

So I start with creating a new table in Bigquery (read and write priveleges are correct) with the following contents:

+-----+-----------+-------------+
| Row | person_id | person_name |
+-----+-----------+-------------+
|   1 |         1 | ABCD        |   
|   2 |         2 | EFGH        |   
|   3 |         3 | IJKL        |   
+-----+-----------+-------------+

This is my code in ruby: (I discovered earlier today that tabledata.insert_all is ruby for tabledata.insertAll - google docs / example need to be updated)

def streaming_insert_data_in_table(table, dataset=DATASET)
    body = {"rows"=>[ 
      {"json"=> {"person_id"=>10,"person_name"=>"george"}},
      {"json"=> {"person_id"=>11,"person_name"=>"washington"}}
    ]}

    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

So I run my code the first time and all appears fine. I see this in the table on Bigquery:

 +-----+-----------+-------------+
 | Row | person_id | person_name |
 +-----+-----------+-------------+
 |   1 |         1 | ABCD        |
 |   2 |         2 | EFGH        |
 |   3 |         3 | IJKL        |
 |   4 |        10 | george      |
 |   5 |        11 | washington  |
 +-----+-----------+-------------+

Then I change the data in the method to:

body = {"rows"=>[ 
      {"json"=> {"person_id"=>5,"person_name"=>"john"}},
      {"json"=> {"person_id"=>6,"person_name"=>"kennedy"}}
    ]}

Run the method and get this in Bigquery:

 +-----+-----------+-------------+
 | Row | person_id | person_name |
 +-----+-----------+-------------+
 |   1 |         1 | ABCD        |
 |   2 |         2 | EFGH        |
 |   3 |         3 | IJKL        |
 |   4 |        10 | george      |
 |   5 |         6 | kennedy     |
 +-----+-----------+-------------+

So, what gives? I've lost data.... (ids 11 and id 5 have vanished) The responses for the request do not have errors either.

Could someone tell me if Im doing something incorrectly or why this is happening please?

Any help is much appreciated.

Thanks and have a great day.

user2989892
  • 63
  • 2
  • 8
  • Would you mind sharing your project and table ids? This is not expected. – Jordan Tigani Nov 26 '13 at 23:20
  • Thanks Jordan, could I send these to you via email please? If so, what address do I send it to? – user2989892 Nov 26 '13 at 23:30
  • Done. Thanks Jordan. Appreciate you looking into this. – user2989892 Nov 26 '13 at 23:51
  • Discovered this appears something to do with the ui (row count doesn't populate for a while and trying to extract the data in the table results in an error "Unexpected. Please try again."). However data is actually stored and can be queried. Thanks for the help Jordan. – user2989892 Dec 02 '13 at 01:58

1 Answers1

0

Discovered this appears something to do with the ui (row count doesn't populate for a while and trying to extract the data in the table results in an error "Unexpected. Please try again."). However data is actually stored and can be queried. Thanks for the help Jordan

user2989892
  • 63
  • 2
  • 8
  • Can you elaborate on what results in an "Unexpected. Please try again" error? Every time you see this error it is a BigQuery bug, and we'd like to figure out what it is so that we can fix it. – Jordan Tigani Dec 02 '13 at 19:59