Prism
v0.1.9rc2
v0.1.9rc2
  • 👋Welcome to Prism!
  • Getting Started
    • Installation
    • Creating your first project
    • Why Prism?
  • Fundamentals
    • Tasks
      • tasks
      • hooks
        • hooks.sql
        • hooks.spark
        • hooks.dbt_ref
    • Targets
      • Multiple targets
    • Config files
      • prism_project.py
        • RUN_ID / SLUG
        • SYS_PATH_CONF
        • THREADS
        • PROFILE_YML_PATH / PROFILE
        • PRISM_LOGGER
        • TRIGGERS_YML_PATH / TRIGGERS
      • Profile YML
      • Triggers YML
    • Jinja
      • __file__ and Path
      • prism_project
      • wkdir
      • parent_dir
      • concat
      • env
  • Adapters
    • Overview
    • sql
      • BigQuery
      • Postgres
      • Redshift
      • Snowflake
      • Trino
    • PySpark
    • dbt
  • Agents
    • Overview
    • Docker
    • EC2
  • CLI
    • Command Line Interface
    • init
    • compile
    • connect
    • create
      • agent
      • task
      • trigger
    • graph
    • run
    • spark-submit
    • agent
      • apply
      • run
      • build
      • delete
  • Advanced features
    • Concurrency
    • Logging
    • Triggers
    • Retries
    • Python Client
  • API Reference
    • prism.task.PrismTask
    • @task(...)
    • @target(...)
    • @target_iterator(...)
    • tasks.ref(...)
    • hooks.sql(...)
    • hooks.dbt_ref(...)
  • Use Cases
    • Analytics on top of dbt
    • Machine Learning
  • Wiki
    • DAGs
Powered by GitBook
On this page
  • Configuration
  • hooks.dbt_ref()
  1. Adapters

dbt

PreviousPySparkNextOverview

Last updated 1 year ago

Configuration

prism enables users to build analytics on top of dbt projects. The configurations for a dbt connection are:

  • project_dir: the directory to your dbt project

  • profiles_dir: the directory to your dbt profile. If one isn't specified, then prism assumes the default dbt profile directory ~/.dbt

  • profiles_target: the profile target you wish to use. More information can be found in the . If your profile has only one target, then this does not need to be specified.

# profile.yml

<profile name here>: # change this!
  adapters:
    <dbt adapter name here>: # change this!
      type: dbt
      project_dir:
      profiles_dir:
      profiles_target:

Under the hood, prism interacts with the dbt architecture to create the project, compile the manifest, getting the target and SQL adapter, and executing the query.

hooks.dbt_ref()

Once connected to a dbt project, users can access dbt models using the hooks.dbt_ref function. This function behaves exactly as the ref function does in dbt. It takes as input a model from your dbt project or a package model and returns it as a pandas DataFrame.

def run(self, tasks, hooks):
    df1 = hooks.dbt_ref('model_name') # Model from your project
    df2 = hooks.dbt_ref('package_name', 'model_name') # Package model

Warning: hooks.dbt_ref does NOT materialize your models for you! You'll need to materialize them yourselve (e.g., with dbt run) before using Prism's hooks.

dbt documentation