All Projects → Johannes-Berggren → firestore-to-bigquery-export

Johannes-Berggren / firestore-to-bigquery-export

Licence: MIT license
NPM package for copying and converting Cloud Firestore data to BigQuery.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to firestore-to-bigquery-export

Spark Bigquery
Google BigQuery support for Spark, Structured Streaming, SQL, and DataFrames with easy Databricks integration.
Stars: ✭ 65 (+150%)
Mutual labels:  bigquery, schema
Fireway
A schema migration tool for firestore
Stars: ✭ 100 (+284.62%)
Mutual labels:  schema, firestore
NoSQLDataEngineering
NoSQL Data Engineering
Stars: ✭ 25 (-3.85%)
Mutual labels:  schema
graphql-liftoff
Generate GraphQL schema language from API specifications and more
Stars: ✭ 44 (+69.23%)
Mutual labels:  schema
transfermarkt-datasets
⚽️ Extract, prepare and publish Transfermarkt datasets.
Stars: ✭ 60 (+130.77%)
Mutual labels:  datasets
managed ml systems and iot
Managed Machine Learning Systems and Internet of Things Live Lesson
Stars: ✭ 35 (+34.62%)
Mutual labels:  bigquery
firestore-explorer
A web based explorer for cloud firestore and emulator
Stars: ✭ 34 (+30.77%)
Mutual labels:  firestore
pod 1.0.2 kaal
Kaal is a productivity suite with beautiful CLI and a Discord Bot.
Stars: ✭ 15 (-42.31%)
Mutual labels:  firestore
react-crud-firestore
A Reactjs CRUD using Firebaes FIrestore as a Database
Stars: ✭ 48 (+84.62%)
Mutual labels:  firestore
awesome-dynamic-graphs
A collection of resources on dynamic/streaming/temporal/evolving graph processing systems, databases, data structures, datasets, and related academic and industrial work
Stars: ✭ 89 (+242.31%)
Mutual labels:  datasets
scrapeOP
A python package for scraping oddsportal.com
Stars: ✭ 99 (+280.77%)
Mutual labels:  datasets
sbt-avro
Plugin SBT to Generate Scala classes from Apache Avro schemas hosted on a remote Confluent Schema Registry.
Stars: ✭ 15 (-42.31%)
Mutual labels:  schema
awesome-mobile-robotics
Useful links of different content related to AI, Computer Vision, and Robotics.
Stars: ✭ 243 (+834.62%)
Mutual labels:  datasets
thermostat
Collection of NLP model explanations and accompanying analysis tools
Stars: ✭ 126 (+384.62%)
Mutual labels:  datasets
pony-capnp
Cap’n Proto plugin for generating serializable Pony classes. 🐴 - 🎩'n 🅿️
Stars: ✭ 19 (-26.92%)
Mutual labels:  schema
decapi
Create GraphQL API by decorating TypeScript classes
Stars: ✭ 81 (+211.54%)
Mutual labels:  schema
Scene-Text-Recognition-Recommendations
Papers, Datasets, Algorithms, SOTA for STR. Long-time Maintaining
Stars: ✭ 215 (+726.92%)
Mutual labels:  datasets
graphql-docker-api
A GraphQL Server for the Docker API
Stars: ✭ 57 (+119.23%)
Mutual labels:  schema
schema-and-structured-data-for-wp
Creating the best Structured Data and Schema plugin for WordPress
Stars: ✭ 66 (+153.85%)
Mutual labels:  schema
git-rdm
A research data management plugin for the Git version control system.
Stars: ✭ 34 (+30.77%)
Mutual labels:  datasets

Firestore to BigQuery export

NPM package for copying and converting Cloud Firestore data to BigQuery.

Software License Packagist Packagist Issues

Firestore is awesome. BigQuery is awesome. But transferring data from Firestore to BigQuery sucks. This package lets you plug and play your way out of config hell.

  • Create a BigQuery dataset with tables corresponding to your Firestore collections.
  • Table schemas are automatically generated based on your document property data types.
  • Convert and copy your Firestore collections to BigQuery.

This package doesn't write anything to Firestore.

Contents

Installation

npm i firestore-to-bigquery-export

import bigExport from 'firestore-to-bigquery-export'

// or

const bigExport = require('firestore-to-bigquery-export')

// then

const GCPSA = require('./Your-Service-Account-File.json')
bigExport.setBigQueryConfig(GCPSA)
bigExport.setFirebaseConfig(GCPSA)

How to

API

bigExport.setBigQueryConfig(
  serviceAccountFile // JSON
)
bigExport.setFirebaseConfig(
  serviceAccountFile // JSON
)
bigExport.createBigQueryTable(
  datasetID, // String
  collectionName, // String
  verbose // boolean
)
// returns Promise<Array>
bigExport.copyToBigQuery(
  datasetID, // String
  collectionName, // String
  snapshot // firebase.firestore.QuerySnapshot
)
// returns Promise<number>
bigExport.deleteBigQueryTable(
  datasetID, // String
  tableName // String
)
// returns Promise<Array>

Examples

/* Create table 'account' in BigQuery dataset 'firestore'. You have to create the dataset beforehand.
 * The given table name has to match the Firestore collection name.
 * Table schema will be autogenerated based on the datatypes found in the collections documents.
 */
await bigExport.createBigQueryTable('firestore', 'accounts')

Then, you can transport your data:

/* Copying and converting all documents in the given Firestore collection snapshot.
 * Inserting each document as a row in tables with the same name as the collection, in the dataset named 'firestore'.
 * Cells (document properties) that doesn't match the table schema will be rejected.
 */
const snapshot = await firebase.collection('payments').get()
const result = await bigExport.copyToBigQuery('firestore', 'payments', snapshot)
console.log('Copied ' + result + ' documents to BigQuery.')

/*
 * You can do multiple collections async, like this.
 * If you get error messages, you should probably copy fewer collections at a time.
 */
const collectionNames = ['payments', 'profiles', 'ratings', 'users']

for (const name of collectionNames) {
  const snapshot = await firestore.collection(name).get()
  await bigExport.copyToBigQuery('firestore', name, snapshot)
}

After that, you may want to refresh your data. For the time being, the quick and dirty way is to delete your tables and make new ones:

// Deleting the given BigQuery table.
await bigExport.deleteBigQueryTable('firestore', 'accounts')

Keep in mind

  • If there's even one prop value that's a FLOAT in your collection during schema generation, the column will be set to FLOAT.
  • If there are ONLY INTs, the column will be set to INTEGER.
  • All columns will be NULLABLE.

Limitations

  • Your Firestore data model should be consistent. If a property of documents in the same collection have different data types, you'll get errors.
  • Patching existing BigQuery sets isn't supported (yet). To refresh your datasets, you can deleteBigQueryTables(), then createBigQueryTables() and then copyCollectionsToBigQuery().
  • Changed your Firestore data model? Delete the corresponding BigQuery table and run createBigQueryTables() to create a table with a new schema.
  • When running this package via a Cloud Function, you may experience that your function times out if your Firestore is large, (Deadline Exceeded). You can then:

Issues

Please use the issue tracker.

To-do

  • Improve the handling of arrays.
  • Implement patching of tables.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].