Amir Jaber
08/18/2023, 2:21 PM@asset( deps = {AssetKey(["full", "path", "upstream_dbt_model_name"]) })
def *my_custom_asset():*
Is there a way to make my_custom_asset
an upstream dependency of all the dbt models which are downstream of the upstream_dbt_model_name
?David Weber
08/18/2023, 2:47 PMAmir Jaber
08/18/2023, 2:55 PMDavid Weber
08/18/2023, 2:55 PMAmir Jaber
08/21/2023, 8:07 AMdagster._core.errors.DagsterInvalidDefinitionError: Asset [‘dagster’, ‘my_source_name’] specifies a schema with its key prefixes [‘dagster’], but schema my_schema_name was also provided via run config. Schema can only be specified one way.For context, here’s how my dbt assets are imported:
@dbt_assets(
manifest=manifest_path,
)
def my_dbt_assets(context: OpExecutionContext, dbt: DbtCliResource):
yield from dbt.cli([“build -f”], context=context).stream()And how my custom asset is initiated
@asset(
deps = {
AssetKey([“integration”, “upstream_dbt_model_name”]),
},
group_name = “python”,
io_manager_key=“io_manager_snowflake”,
key=get_asset_key_for_source([my_dbt_assets], “dagster”),
)
def my_source_name(context):
David Weber
08/21/2023, 8:11 AMAmir Jaber
08/21/2023, 8:38 AMmy_custom_asset
. Then I make sure my_custom_asset is named the same as that source and is connected to it using this syntax. Is there more nuance here that I might be missing?David Weber
08/21/2023, 1:04 PM@asset(...)
def my_last_dagster_asset():
# this asset outputs data, which I want to use as a source in dbt
And then in order to define this as a source, you do the following in dbt in your `sources.yml`:
version: 2
sources:
- name: my_name
tables:
- name: my_last_dagster_asset
meta:
dagster:
asset_key: ["my_last_dagster_asset"]
And of course you use this source in your dbt model now:
select * from {{ source("dagster", "my_last_dagster_asset") }}
And bam - you have the dependency from your last dagster asset to your first dbt model. There will be no specific "source asset" in dagster, as typically your "source" is the output of your last dagster asset anyway.
This is defined here: https://docs.dagster.io/integrations/dbt/reference#upstream-dependenciesAmir Jaber
08/28/2023, 4:07 PMDavid Weber
08/28/2023, 4:19 PM