Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google bigquery update rows

So can anyone give ideas on how to update a set of rows?

I understand the concept of query -> new table, then dumping the "old" table and re-naming the "new", but to be honest this is very hokey.

I don't see anything in the documentation, web, or in the new ideas that will lead me to believe in the appearance of an "update" statement either.

Thoughts anyone?

like image 449
user2788456 Avatar asked Sep 17 '13 16:09

user2788456


People also ask

Can you update rows in BigQuery?

BigQuery manages the concurrency of DML statements that add, modify, or delete rows in a table.

How do you overwrite data in BigQuery?

To append to or overwrite a table using query results, specify a destination table and set the write disposition to either: Append to table — Appends the query results to an existing table. Overwrite table — Overwrites an existing table with the same name using the query results.

How do you refresh a table in BigQuery?

To update to the latest BigQuery data, at the bottom of the pivot table, click Refresh.


2 Answers

On September 29, 2016, Google update there DML, and now we can write standard SQL, which enables us to insert, update, and delete rows and columns in your BigQuery datasets.

like image 123
vladi03 Avatar answered Sep 28 '22 06:09

vladi03


[UPDATE This answer is out-of-date]

BigQuery does not currently support direct updates to individual rows. You can append to a table, and you can truncate/overwrite a table, but you cannot apply an update to a single row while leaving the rest of the table untouched.

The flow you mentioned (create new table, replace old table) is a reasonable approach. If it helps, note that you do not need two separate steps to replace the old table with the new table. Since BigQuery applies job side-effects atomically, you can replace the old table in one step by setting the writeDisposition on the final copy job to WRITE_TRUNCATE. For example, you could do the following:

  query table -> table with WRITE_TRUNCATE

Just like an update, you should note that this is destructive to the old table. However, if you didn't change the schema, you can use a snapshot decorator to read the table as of a time before the truncate occurred.

While this update process is occurring, you can have query jobs running against "table", and those jobs are guaranteed to see either the old content or the new content, with no inconsistent or erroneous states in between.

like image 28
Jeremy Condit Avatar answered Sep 28 '22 07:09

Jeremy Condit