hooks.dbt_ref(...)

Function used to retrieve already materialized dbt models as Pandas DataFrames.

hooks.dbt_ref(adapter_name: str, target_1: str, target_2: Optional[str] = None, target_version: Optional[str] = None)

  • Parameters

    • adapter_name: the adapter defined in the projects profile YML to execute the query

    • target_1: dbt model (or package)

    • target_2: dbt model (if target_1 is a package). Default is None.

    • target_version: the versioned model to use. Default is None, in which case the latest version is. See here for more details.

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.

  • Example:

import prism.task
import prism.target
import prism.decorators

import pandas as pd

class GetDbtModel(prism.task.PrismTask):
    
    def run(self, tasks, hooks):
        df: pd.DataFrame = hooks.dbt_ref("my_model")
        return df

Last updated