All Projects → Dashlane → dbt-invoke

Dashlane / dbt-invoke

Licence: Apache-2.0 license
A CLI for creating, updating, and deleting dbt property files

Programming Languages

python
139335 projects - #7 most used programming language

Labels

Projects that are alternatives of or similar to dbt-invoke

tellery
Tellery lets you build metrics using SQL and bring them to your team. As easy as using a document. As powerful as a data modeling tool.
Stars: ✭ 219 (+421.43%)
Mutual labels:  dbt
dbt ad reporting
Fivetran's ad reporting dbt package. Combine your Facebook, Google, Pinterest, Linkedin, Twitter, Snapchat and Microsoft advertising spend using this package.
Stars: ✭ 68 (+61.9%)
Mutual labels:  dbt
fal
do more with dbt. fal helps you run Python alongside dbt, so you can send Slack alerts, detect anomalies and build machine learning models.
Stars: ✭ 567 (+1250%)
Mutual labels:  dbt
airflow-dbt-python
A collection of Airflow operators, hooks, and utilities to elevate dbt to a first-class citizen of Airflow.
Stars: ✭ 111 (+164.29%)
Mutual labels:  dbt
dbt-spotify-analytics
Containerized end-to-end analytics of Spotify data using Python, dbt, Postgres, and Metabase
Stars: ✭ 92 (+119.05%)
Mutual labels:  dbt
dbt-airflow-docker-compose
Execution of DBT models using Apache Airflow through Docker Compose
Stars: ✭ 76 (+80.95%)
Mutual labels:  dbt
snowflake-starter
A _simple_ starter template for Snowflake Cloud Data Platform
Stars: ✭ 31 (-26.19%)
Mutual labels:  dbt
dataops-platform-airflow-dbt
Build DataOps platform with Apache Airflow and dbt on AWS
Stars: ✭ 33 (-21.43%)
Mutual labels:  dbt
metriql
The metrics layer for your data. Join us at https://metriql.com/slack
Stars: ✭ 227 (+440.48%)
Mutual labels:  dbt
dbt-formatter
Formatting for dbt jinja-flavored sql
Stars: ✭ 37 (-11.9%)
Mutual labels:  dbt
awesome-dbt
A curated list of awesome dbt resources
Stars: ✭ 520 (+1138.1%)
Mutual labels:  dbt
PyRasgo
Helper code to interact with Rasgo via our SDK, PyRasgo
Stars: ✭ 39 (-7.14%)
Mutual labels:  dbt
dbt2looker
Generate lookml for views from dbt models
Stars: ✭ 119 (+183.33%)
Mutual labels:  dbt
dbt-on-airflow
No description or website provided.
Stars: ✭ 30 (-28.57%)
Mutual labels:  dbt
spark-utils
Utility functions for dbt projects running on Spark
Stars: ✭ 19 (-54.76%)
Mutual labels:  dbt
pre-commit-dbt
🎣 List of `pre-commit` hooks to ensure the quality of your `dbt` projects.
Stars: ✭ 149 (+254.76%)
Mutual labels:  dbt
dbt ml
Package for dbt that allows users to train, audit and use BigQuery ML models.
Stars: ✭ 41 (-2.38%)
Mutual labels:  dbt
dbt artifacts
A dbt package for modelling dbt metadata. https://brooklyn-data.github.io/dbt_artifacts
Stars: ✭ 119 (+183.33%)
Mutual labels:  dbt
dbt-cloud-plugin
DBT Cloud Plugin for Airflow
Stars: ✭ 35 (-16.67%)
Mutual labels:  dbt
dbt-sugar
dbt-sugar is a CLI tool that allows users of dbt to have fun and ease performing actions around dbt models
Stars: ✭ 139 (+230.95%)
Mutual labels:  dbt

dbt-invoke

dbt-invoke is a CLI (built with Invoke) for creating, updating, and deleting dbt property files.

  • Supported dbt resource types:

    • models
    • seeds
    • snapshots
    • analyses
  • Under the hood, this tool works by combining the power of the dbt ls and dbt run-operation commands with dbt's built-in get_columns_in_query macro.

    • This methodology allows the tool to work on ephemeral models and analyses, which other approaches, such as those based on listing data warehouse tables/views, can miss.

Installation

pip install dbt-invoke

Usage

  • You must have previously executed dbt run/dbt seed/dbt snapshot on the resources for which you wish to create/update property files.

    • If you have made updates to your resources, execute the appropriate command (dbt run/dbt seed/dbt snapshot) before using this tool to create/update property files.
  • Property files will be created, updated, or deleted on a one-to-one basis in the same paths as the resource files they represent (the only change being a .yml file extension).

    • For example, given a resource file in the location models/marts/core/users.sql, this tool will create, update, or delete a property file in the location models/marts/core/users.yml.
  • Any newly generated property files are created with the correct resource type, resource name, and columns. A blank description field will be included for each column and for the resource itself.

    • For example, when generating a new property file for a model users with column names user_id and created_at, the following yaml will be generated:
      • version: 2
        models:
        - name: users
          description: ''
          columns:
          - name: user_id
            description: ''
          - name: created_at
            description: ''
  • When updating an already existing property file, new columns in the resource will be added, and columns that no longer exist will be removed.

  • You may fill in the blank description properties and add other properties (e.g. tests). They will remain intact when updating existing property files as long as the column/resource name to which they belong still exists.

Creating/Updating Property Files

dbt-invoke properties.update <options>

# OR, because 'update' is set as the default command:
dbt-invoke properties <options>
  • The first time you run this command, you should be prompted to add a short macro called _log_columns_list to your dbt project.

    • You may accept the prompt to add it automatically.
    • Otherwise, copy/paste it into one your dbt project's macro-paths yourself.
    • To print the macro, at any time, run dbt-invoke properties.echo-macro.
  • <options> primarily uses the same arguments as the dbt ls command to allow flexibility in selecting the dbt resources for which you wish to create/update property files (run dbt ls --help for details).

    • --resource-type
    • --models
    • --select
    • --selector
    • --exclude
    • --project-dir
    • --profiles-dir
    • --profile
    • --target
    • --vars
    • --bypass-cache
    • --state
  • Notes:

    • This tool supports only the long flags of dbt ls options (for example: --models, and not short flags like -m).
    • Multiple values for the same argument can be passed as a comma separated string (Example: --models modelA,modelB)
      • Keep in mind that dbt may not support multiple values for certain options.
  • Two additional flags are made available.

    • --log-level to alter the verbosity of logs.
      • It accepts one of Python's standard logging levels (debug, info, warning, error, critical).
    • --threads to set a maximum number of concurrent threads to use in collecting resources' column information from the data warehouse and in creating/updating the corresponding property files. Each thread will run dbt's get_columns_in_query macro against the data warehouse.
  • Some examples:

    # Create/update property files for all supported resource types
    dbt-invoke properties
    
    # Create/update property files for all supported resource types, using 4 concurrent threads
    dbt-invoke properties --threads 4
    
    # Create/update property files for all models in a models/marts directory
    dbt-invoke properties --models marts
    
    # Create/update property files for a 'users' model and an 'orders' models
    dbt-invoke properties --models users,orders
    
    # Create/update property files for a 'users' model and all downstream models
    dbt-invoke properties --models users+
    
    # Create/update property files for all seeds
    dbt-invoke properties --resource-type seed
    
    # Create/update a property file for a snapshot called 'users_snapshot'
    dbt-invoke properties --resource-type snapshot --select users_snapshot
    
    # Create/update property files when your working directory is above your dbt project directory
    dbt-invoke properties --project-dir path/to/dbt/project/directory

Deleting Property Files

dbt-invoke properties.delete <options>
  • <options> uses the same arguments as for creating/updating property files, except for --threads.

Help

  • To view the list of available commands and their short descriptions, run:

    dbt-invoke --list
  • To view in depth command descriptions and available options/flags, run:

    dbt-invoke <command_name> --help

Limitations

  • dbt-invoke will try to preserve formatting and comments when updating existing files. If you want to preserve line-breaks, use > or | on your multiline strings, as recommended here.
  • In order to collect or update the list of columns that should appear in each property file, dbt's get_columns_in_query macro is run for each matching resource. As of the time of writing, get_columns_in_query uses a SELECT statement limited to zero rows. While this is not typically a performance issue for table or incremental materializations, execution may be slow for complex analyses, views, or ephemeral materializations.
    • This may be partially remedied by increasing the value of the --threads option in dbt-invoke properties.update.
  • dbt-invoke is tested against:
    • Python 3.7 and 3.9
    • dbt 0.18, 0.19, and 1.0
    • macos-latest, windows-latest, ubuntu-latest
  • dbt-invoke has not been tested across different types of data warehouses.
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].