Logo

dev-resources.site

for different kinds of informations.

How to Stream Data From Firebase to BigQuery Easily

Published at
6/24/2023
Categories
firebase
bigquery
googlecloud
firestore
Author
debosthefirst
Author
13 person written this
debosthefirst
open
How to Stream Data From Firebase to BigQuery Easily

You must have installed the Stream Firestore to Big Query Extension and maybe even read some of the docs but you still can’t quite figure out how to get everything to work. This guide will help you with that.

Have data in Firebase Firestore and need to bring them into Big Query? That’s a little straightforward. You simply export the data into a bucket and pull the data into your Big query console. There are a few articles online that explain this well, particularly this.

But, when it comes to streaming data in realtime from Firestore to BQ, I couldn’t find any good articles there that could get me from start to finish without errors — so, I wrote one.

This guide assumes you have an existing Firestore instance setup and one or more collections in your Firestore DB. Next, within your Firebase console, navigate to the extensions screen. Search for and install the Stream Firestore to BigQuery extension.

Once in, set up the extension by following the prompts.

NB: You’ll only be able to use the extension if your workspace or account has a Credit card on file.

Keep hitting next till you get to Step 4: Configure extension.

Set your Project Id, Collection Path, Dataset ID and Table ID. Project ID should be the same as whatever you have named your firebase project. Collection path refers to the primary collection you would like to stream to BQ. In our case, we want the users collection. Dataset ID and Table ID can be named as you wish. Keep all other configurations as default and hit the install button.

The extension will take around 3–5mins to install.

At this point, there’s no new data in your BQ console just yet.

While waiting on the extension’s installation to complete, you can begin the process of setting up gcloud CLI. You’ll need to set up the CLI in order to authenticate when running the import script that will take your data from Firestore to BQ.

Follow the instructions here to set up the CLI for your device. Don’t forget to make sure the CLI is in your PATH by running (on a Mac) — in your HOME directory.

./google-cloud-sdk/install.sh
Enter fullscreen mode Exit fullscreen mode

Restart your terminal instance before continuing.

With the CLI setup. Run the command below in your terminal window to authenticate.

gcloud auth application-default login
Enter fullscreen mode Exit fullscreen mode

The command will bring you to the Google sign-in screen. Authenticate using the E-mail that has access to the Firestore project you’re working with.

You’ll see a screen like below if everything goes fine.

Your terminal should also have a message like below

Google has an import script that will allow you to automatically bring all the data in your Firestore collection into BigQuery by running one command. This script works alongside the Stream Firestore to BigQuery extension. Run the command below in your terminal to trigger the script.

npx @firebaseextensions/fs-bq-import-collection
Enter fullscreen mode Exit fullscreen mode

P.S The command above will only work if you have Node/NPM installed.

Follow the prompts starting with entering your project ID. You only need to enter the custom information we set earlier — project ID, Dataset ID, Table prefix and Collection Path. See screenshot below.

The script will create a raw_changelog file in the format table_name_raw_changelog. Once you navigate to your BigQuery console, you would be able to see this.

You can also run queries on your data using the Compose a new query button

Now, you can add a new document to the users collection, refresh your table within BigQuery and observe that the new document reflects in your BigQuery query!

firestore Article's
30 articles in total
Favicon
Dev Video Review: Firestore Data Structure, Limitations, and IMHO
Favicon
Do you need a No Code tool for Firebase?
Favicon
Firebase: The Ultimate Backend for Your CMS
Favicon
NgSysV2-10.1: Firestore CRUD templates
Favicon
NgSysV2-3.3: A Serious Svelte InfoSys: Firebase D/b rules and Login
Favicon
NgSysV2-3.4: A Serious Svelte InfoSys: Rules-friendly version
Favicon
NgSysV2-3.5: A Serious Svelte InfoSys: Client-Server Version
Favicon
Dive into the world of serverless - GCP Edition
Favicon
Visualizing Firebase Data: Unlocking the Power of Real-Time Insights
Favicon
Implementing Batch Write Operations in Firestore with Express
Favicon
Enforcing Firebase App Check for Firestore with Initialization Configuration
Favicon
Retrieving User Roles from Firestore in a Next.js Application
Favicon
How to Keep Your Custom Claims in Sync with Roles Stored in Firestore
Favicon
Scheduling Events in Firebase Firestore with Server Timestamps
Favicon
Using Google Cloud Firestore with Django's ORM
Favicon
Firebase Realtime Database vs Cloud Firestore
Favicon
Real-Time Data Handling with Firestore: Tracking Pending Orders
Favicon
How to programmatically backup your Firestore database with simple steps
Favicon
Understanding Real-Time Data with Firebase Firestore in JavaScript
Favicon
Enabling Offline Capabilities in Firebase with IndexedDB Persistence
Favicon
Querying Firestore for Capital Cities with JavaScript
Favicon
Explorando o Firebase: Uma Plataforma Poderosa para Desenvolvimento de Aplicativos
Favicon
Using Firestore in Apps Script
Favicon
What is Flutter, how do I get started ??!!!
Favicon
How to Stream Data From Firebase to BigQuery Easily
Favicon
Retrieve a list of data under specific user collection in flitter
Favicon
Tentando não ficar pobre antes de ficar rico criando uma Startup de serviços de inteligência artificial
Favicon
Trying to Maintain a Workable Budget Creating a Chatbot Using GPT and Vector Database
Favicon
Uptime Monitoring with Firebase
Favicon
Firestore data modeling

Featured ones: