Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does BigQuery support UPDATE, DELETE, and INSERT (SQL DML) statements?

BigQuery supports SELECT statements, but does it support DML statements like INSERT, UPDATE and DELETE?

like image 337
Pavan Edara Avatar asked Aug 12 '16 16:08

Pavan Edara


People also ask

Does BigQuery supports SQL?

BigQuery supports the Google Standard SQL dialect, but a legacy SQL dialect is also available. If you are new to BigQuery, you should use Google Standard SQL as it supports the broadest range of functionality. For example, features such as DDL and DML statements are only supported using Google Standard SQL.

Which of these data sources are supported in BigQuery?

BigQuery supports the following external data sources: Bigtable. Cloud Spanner. Cloud SQL.

Is update a DML command?

DML is Data Manipulation Language and is used to manipulate data. Examples of DML are insert, update and delete statements.

Does BigQuery support DML statements like insert?

Bookmark this question. Show activity on this post. BigQuery supports SELECT statements, but does it support DML statements like INSERT, UPDATE and DELETE? Show activity on this post. Yes, BigQuery now supports SQL DML with standard SQL (uncheck “Use Legacy SQL” under “Show Options”). SQL DML is not supported with legacy SQL.

How do I update data in BigQuery?

The BigQuery data manipulation language (DML) enables you to update, insert, and delete data from your BigQuery tables. For information about how to use DML statements, see Data manipulation language. Use the INSERT statement when you want to add new rows to a table. INSERT statements must comply with the following rules:

What is BigQuery data manipulation language?

The BigQuery data manipulation language (DML) enables you to update, insert, and delete data from your BigQuery tables. You can execute DML statements just as you would a SELECT statement, with the following conditions:

Is DML supported with legacy SQL?

SQL DML is not supported with legacy SQL. 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. Show activity on this post.


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.

like image 135
Pavan Edara Avatar answered Oct 13 '22 22:10

Pavan Edara


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
)
like image 32
Zakaria.dem Avatar answered Oct 13 '22 21:10

Zakaria.dem