<@U01AV4K3W14> how does the old `source_key_prefix...
# integration-dbt
g
@rex how does the old
source_key_prefix
map to the new DBT API?
node_info_to_asset_key
(https://github.com/dagster-io/dagster/discussions/14477) no longer seems to be available in the latest version? For the normal prefix operation https://docs.dagster.io/integrations/dbt/reference#loading-dbt-models-from-a-dbt-project lists the
Copy code
self.get_asset_key(dbt_resource_props).with_prefix("snowflake")
but that is not tackling/documenting the source_key_prefix
🤖 1
r
I added a new example here, since another user had a similar question: https://github.com/dagster-io/dagster/pull/15814. You can just use
dbt_resource_props
to scope the change only for sources.
Copy code
from typing import Any, Mapping

                from dagster import AssetKey
                from dagster_dbt import DagsterDbtTranslator


                class CustomDagsterDbtTranslator(DagsterDbtTranslator):
                    @classmethod
                    def get_asset_key(cls, dbt_resource_props: Mapping[str, Any]) -> AssetKey:
                        asset_key = super().get_asset_key(dbt_resource_props)

                        if dbt_resource_props["resource_type"] == "source":
                            asset_key = asset_key.with_prefix("my_prefix")

                        return asset_key
g
cool
in fact I want it for both