https://dagster.io/ logo
Title
a

Ajith Kumar

05/19/2023, 8:33 AM
Hi I'm using
load_assets_from_dbt_manifest
. Can someone let me know how to pass dbt variables in this . I could see that
partition_key_to_vars_fn
can be used for this from the documentation. But it expects a string and dbt var needs to passed as dict so I'm not sure how to processed on this.. On the below code snippet the following dbt variable needs to passed { "load_date" : "2023-05-19" , "condition": ">=" }
dbt_assets = load_assets_from_dbt_manifest(
    manifest_json, 
    select="model_x"
)
o

owen

05/19/2023, 4:51 PM
hi @Ajith Kumar! the partition_key_to_vars_fn is intended for use with partitioned assets. This may be what you want (rather than hard-coding a specific load_date), in which case the partition_key_to_vars_fn would take as input a string, but return a dictionary. So that would look something like
def my_partition_key_to_vars_fn(partition_key: str):
    return { "load_date" :   partition_key , "condition": ">=" }
:thank-you-box: 1
If you do just want to hard code those vars, you can configure the dbt_cli_resource with {..., "vars": { "load_date" : partition_key , "condition": ">=" }}