npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

bigquery-porter

v0.2.8

Published

BigQuery Porter is a tool to manage BigQuery Metadata and Deployment.

Downloads

72

Readme

BigQuery Porter

CI - testing

BigQuery Porter is a tool to manage BigQuery Resource and its metadata by filesystem.

Demo

Get Started

Installation

npm i bigquery-porter

Set up your OAuth and GCP Default Project.

Clone BigQuery resources from your GCP Project

First step to start to use is cloning BigQuery resources as files in remote. Next comamnd, you'll get BigQuery metadata files and DDL codes in local filesystem.

npx bqport pull --all --with-ddl

Typical directory strucuture follows:

(Root Directory)
`-- @default: Your Default GCP Project
    `-- sandbox
        |-- ddl.sql
        |-- metadata.json
        |-- @models
        |   `-- mymodel
        |       |-- ddl.sql
        |       `-- metadata.json
        |-- @routines
        |   |-- sample_function
        |   |   |-- ddl.sql
        |   |   `-- metadata.json
        |   |-- sample_procedure
        |   |   |-- ddl.sql
        |   |   `-- metadata.json
        |   `-- sample_tvf
        |       |-- ddl.sql
        |       `-- metadata.json
        |-- sample_clone_table
        |   |-- ddl.sql
        |   |-- metadata.json
        |   `-- schema.json
        |-- sample_materialized_view
        |   |-- ddl.sql
        |   |-- metadata.json
        |   `-- schema.json
        |-- sample_partition_table
        |   |-- ddl.sql
        |   |-- metadata.json
        |   `-- schema.json
        |-- sample_snapshot_table
        |   |-- ddl.sql
        |   |-- metadata.json
        |   `-- schema.json
        |-- sample_table
        |   |-- ddl.sql
        |   |-- metadata.json
        |   `-- schema.json
        `-- sample_view
            |-- metadata.json
            |-- schema.json
            `-- view.sql

`-- <other_projects>

Deploy Your BigQuery Resources

After you modifeid files in locals, you can deploy them by next command: The following command will deploy to the default project in GCP.

npx bqport push

bqport deploys codes in prallel and topological order by SQL's DAG dependencies.

Partial Deployment from STDIN

You can also deploy your BigQuery queries from a list of SQL files. This is useful for cases where you want to execute only specific SQL. For example, a diff execution by git.

find ./bigquery -name '*.sql' | npx bqport push

Dependency Resolution Behavior

bigquery-porter resolves dependencies in following order

  1. DDL(DROP): DROP TABLE statement
  2. DDL(CREATE): CREATE TABLE statement
  3. DDL(ALTER): ALTER TABLE statement
  4. DML: INSERT INTO, DELETE,TRUNCATE, MERGE statements
  5. QUERY

Tips

Vendoring BigQuery Datasets

For Example, Let's copy public datasets in bqutil project .

  1. Fetch Dataset Metadata and DDL SQL file
npx bqport pull bqutil --all --with-ddl
  1. Make your new destination project directory and copy files
mkdir -p bigquery/@default
cp -av bigquery/bqutil/fn bigquery/@default/fn
  1. Fix old destination in SQL files to new one
npx bqport format
  1. Deploy
npx bqport push @default