GCP BigQuery
BigQuery is one of the most popular data warehouses in the world. Webhook Relay functions allow directly inserting data into them.
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.
Streaming data to GCP BigQuery
Check if record exists
A simple query to check whether a row exists by matching a column with a value:
Execute any command
To execute any SQL command on your table:
BigQuery package API reference
At the moment there’s a single client method that bigquery package exposes:
Limitations
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.
Troubleshooting
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.
Last updated