Load data into a BigQuery table from Google Cloud Storage using SQL

A short code example which loads a csv file from Google Cloud Storage into a table using SQL.

-- load data from Google Cloud storage into a BigQuery table
-- Google docs: https://cloud.google.com/bigquery/docs/loading-data-cloud-storage-csv#csv-options


LOAD DATA OVERWRITE destination_dataset.destination_table_name
(sepal_length NUMERIC,sepal_width NUMERIC, petal_length NUMERIC,petal_width NUMERIC ,class STRING)
FROM FILES (
  format = 'CSV',
  field_delimiter = ',',
  uris = ['gs://your-bucket-with-some-data-inside/iris.csv'],
  max_bad_records = 1);

Send a Comment

Your email address will not be published.