How to handle asset dbt models with an `alias` con...
# ask-community
b
How to handle asset dbt models with an
alias
config? dbt model with the file name
my_schema___my__table.sql
Copy code
{{ config(alias="my_table") }}}

SELECT 1
the asset key will be
my_schema / my_schema___my__table
downstream asset using dagster-snowflake io manager
Copy code
@asset(
  in={"my_schema__mytable": AssetIn(key_prefix=["my_schema"])
  ...
)
def my_asset(my_schema__my_table: DataFrame):
   ...
the io manager would do a
select * from <http://my_schema.my|my_schema.my>__schema____my__table
, which doesnt exist
o
hi @Binh Pham! One option would be to customize how asset keys are generated, which you can do by passing in a
node_info_to_asset_key
parameter into your load_assets_from_dbt... function. This would be a function that takes a dictionary of information about each dbt model and returns an asset key. You can see the default implementation here: https://sourcegraph.com/github.com/dagster-io/dagster/-/blob/python_modules/libraries/dagster-dbt/dagster_dbt/asset_defs.py?L132:5. In your case, I think you'd like to use
node_info.get("alias") or node_info["name"]
in place of
node_info["name"]
in your function
❤️ 1
arguably, the default should work as you're describing, but we try pretty hard not to make backwards-incompatible changes on this sort of thing
b
thank you @owen that worked!
117 Views