dbt - how can you use python in your dbt project

We can use python in our dbt project as well. Here is an example of code that you can place under model folder



def model(dbt, session):

    dbt.config(materialized='table')
   
    source_store_sales = dbt.source('SNOWFLAKE_SAMPLE_DATA', 'store_sales')
   
    return source_store_sales


This is equilvalent to :



{{ config(materialized='view')}}

with

source_store_sales as (
    select * from {{ source('SNOWFLAKE_SAMPLE_DATA', 'store_sales') }}
),

renamed as (
    select
      *
    from source_store_sales
)

select * from renamed

There are limitation when using python code where it only supports table and incremental. 














Comments

Popular posts from this blog

Windows SSH: Permissions for 'private-key' are too open

NodeJS: Error: spawn EINVAL in window for node version 20.20 and 18.20