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

dataform-osmosis

v0.2.2

Published

dataform-osmosis is a CLI tool for refactoring and managing Dataform SQLX files.

Downloads

288

Readme

Dataform Osmosis

Build Status npm version license

dataform-osmosis is a CLI tool for refactoring and managing Dataform SQLX files.

Note: This project, dataform-osmosis, was inspired by dbt-osmosis.

It allows users to automatically update column information by synchronizing with BigQuery table schemas, reorder columns based on actual BigQuery tables, and inherit column descriptions from referenced tables. This is especially useful when working with complex SQLX files and maintaining consistency between Dataform and BigQuery.

Features

  • Synchronize SQLX with BigQuery: Automatically update column information from the actual BigQuery tables.
  • Inherit Column Descriptions: Inherit column descriptions from tables referenced in SQLX files, based on column names.

Installation

To install dataform-osmosis, use the following commands:

npm install -g dataform-osmosis

Alternatively, if you're developing locally, you can link the package:

npm link

Configuration

You can specify workflow settings in a workflow_settings.yaml file, similar to the default Dataform CLI settings:

defaultProject: your-project-id
defaultLocation: asia-northeast1
defaultDataset: dataform
defaultAssertionDataset: dataform_assertions

You can also specify settings in a dataform.json file.

{
    "defaultProject": "your-project-id",
    "defaultLocation": "asia-northeast1",
    "defaultDataset": "dataform",
    "defaultAssertionDataset": "dataform_assertions"
}

Setting Up Google Cloud Authentication

dataform-osmosis uses the Google Cloud BigQuery client internally, which requires authentication. For authentication, please use one of the methods described in the Google Cloud documentation: Application Default Credentials .

By following these authentication methods, the BigQuery client within dataform-osmosis will be able to access your project resources and provide full functionality.

Setting Up Dataform CLI

dataform-osmosis relies on the @dataform/cli commands internally, so you’ll need to install and configure the Dataform CLI to use the tool effectively.

To install the Dataform CLI, use the following command:

npm i -g @dataform/cli

For detailed setup instructions and usage, please refer to the official Dataform CLI documentation: Using the Dataform CLI .

Usage

The tool provides various commands to refactor SQLX files and manage Dataform projects.

Validate the Dataform project

You can validate the current Dataform project to ensure all configurations are correct by running: This command checks the BigQuery configuration and ensures the Dataform CLI is properly set up.

dataform-osmosis valid

Refactor SQLX files

To refactor SQLX files by updating column information and reordering columns, use the refactor command:

dataform-osmosis refactor -f [file_or_directory]

For example:

dataform-osmosis refactor -f definitions/marts/test

This command refactors all SQLX files within the definitions/marts/test directory, or a single SQLX file if specified. It performs the following operations:

  1. Add missing columns: Adds columns that exist in BigQuery but are missing in the SQLX file.
  2. Reorder columns: Ensures columns are in the correct order as in BigQuery.
  3. Inherit column descriptions: Copies column descriptions from referenced tables when columns share the same name.

Example

Given the following SQLX configuration in a file:

config {
  type: "table",
  schema: "dataform",
  columns: {
    id: "id",
    name: {
      description: "Name of the user",
    }
  }
}

If the BigQuery table has an additional column age and the referenced table has the same column name with a description, dataform-osmosis will update the SQLX file to include the missing column and update descriptions where needed.

Development

If you're contributing to dataform-osmosis or developing locally, follow these steps to set up your environment:

1. Install dependencies

npm install

2. Run tests

You can run tests using the following command:

npm test

Tests are written with Jest to ensure that the tool behaves as expected.

3. Link the package locally

For local development and testing, you can link the package:

npm link

This allows you to use the dataform-osmosis command globally during development.

License

dataform-osmosis is licensed under the Apache-2.0 License.

Issues & Contributing

If you encounter any issues or have feature requests, please submit them via the GitHub Issues page. Contributions are welcome! Please refer to the Contributing Guidelines for more information.