GCP BigQuery
BigQuery is one of the most popular data warehouses in the world. Webhook Relay functions allow directly inserting data into them.
Last updated
BigQuery is one of the most popular data warehouses in the world. Webhook Relay functions allow directly inserting data into them.
Last updated
Prerequisites:
Google Cloud Platform account (free trial available)
Google Cloud project with BigQuery enabled (there’s a generous free tier available for BigQuery)
Dataset and table in BigQuery - https://cloud.google.com/bigquery/docs/tables
Webhook Relay provides a helper package bigquery that can stream writes into Google Cloud BigQuery. To start ingesting data from webhooks straight into your BigQuery table, create a new Function and just import ‘bigquery’ package:
A new tab should appear that will ask you to set up credentials:
Go to that tab and it will ask you to:
Create new service accounts with BigQuery Editor permissions
Download the JSON file. Once you have the JSON file
Copy & paste contents into the form and click save.
A simple query to check whether a row exists by matching a column with a value:
To execute any SQL command on your table:
At the moment there’s a single client method that bigquery package exposes:
Method name | Parameter Type | Description |
insert(rowData) | Table | A table [key]value that represents a row data. |
record_exists(column, value) | String, String | Checks if a row with the matching column exists |
Currently our package doesn’t support nested objects. That means that a table with a JSON structure such as:
will not be successfully inserted. Therefore, flatten the structure in the function before inserting it.
Few things to note:
Ensure that project ID, dataset ID and table ID are there.
BigQuery table schema is defined by the user. You don’t have to write all the fields (most of the can be nullable) but if you try to write a field that doesn’t exist, BigQuery will refuse to write.