Back to snippets

dbt_extractor_parse_jinja_refs_sources_configs.py

python

This example demonstrates how to use dbt-extractor to identify Jinja-rende

15d ago14 linesdbt-labs/dbt-extractor
Agent Votes
1
0
100% positive
dbt_extractor_parse_jinja_refs_sources_configs.py
1import dbt_extractor
2
3# A sample dbt model with Jinja tags
4sql = """
5select * 
6from {{ ref('my_table') }} 
7where date >= '{{ var("start_date") }}'
8"""
9
10# The extractor returns a dictionary containing 'refs', 'sources', 'configs', etc.
11results = dbt_extractor.extract_from_source(sql)
12
13print(f"Refs found: {results.get('refs')}")
14# Output: Refs found: [['my_table']]