BigQuery supports SELECT statements, but does it support DML statements like INSERT, UPDATE and DELETE?
2 Answers
Yes, BigQuery now supports SQL DML with standard SQL (uncheck “Use Legacy SQL” under “Show Options”). SQL DML is not supported with legacy SQL.
Official documentation is available here: https://cloud.google.com/bigquery/sql-reference/data-manipulation-language
NOTE: UPDATE, DELETE and MERGE DML statements are supported over tables with streaming buffer as long as the statement doesn't affect rows that are in the streaming buffer.
-
1Thanks for the feedback. Official documentation is coming for this alpha release in the near future but we would like to make it available at the earliest for our users to go ahead and try so we can get your feedback. Aug 12, 2016 at 16:48
-
1Mikhail, I assure you that we'll have proper broad announcements when this goes Beta. This is an early Alpha release, and we hope to gather user feedback here.– vgtAug 12, 2016 at 16:51
-
4@MikhailBerlyant - what do you think about using StackOverflow as our official pre-announcement channel? Everything will be documented and added to the release notes eventually, but if we have to pre-announce anywhere... why not reward our awesome StackOverflow community. Aug 12, 2016 at 18:06
-
3honestly! somehow I feel SO is not right place/channel for announcements! just my opinion. Aug 12, 2016 at 18:09
-
1@MikhailBerlyant - challenge: Everything will end up eventually in cloud.google.com/bigquery, but we are looking for a way to share with a smaller community stuff that's not ready for prime time. We have other programs for that too, but if I had to choose my favorite is this one (including all your contributions). Aug 12, 2016 at 19:44
I have tested a DELETE statement with BigQuery API, it work well for me. this is the source code in GCP composer (airflow)
from airflow.contrib.operators.bigquery_operator import BigQueryOperator
bq_delete_task = BigQueryOperator(
dag = dag,
task_id = 'remove_from_table_bq',
destination_dataset_table = False,
destination_table = 'table_name',
bql = "DELETE FROM " + BQ_DATASET_NAME + "." + "table_name" + " WHERE date = '2018-06-06'",
use_legacy_sql = False
)