Closed SeppBerkner closed 3 months ago
Hey @SeppBerkner! When you configure custom schema the asset key for your model is different: https://github.com/dagster-io/dagster/blob/3a990132069004eea64c823bdb7676dca8b006fa/python_modules/libraries/dagster-dbt/dagster_dbt/asset_utils.py#L431-L435
To define your job and select the asset by the key use this selection:
my_model_job = define_asset_job(
name = "my_model_job",
selection = "*my_custom_schema/my_model",
description = "job to create my model"
)
Great! This was it. Thanks @marchinho11
Hi, I also faced this problem. How can I resolve it in like defining dbt asset ? Here is my dbt asset code:
from dagster import AssetExecutionContext
from dagster_dbt import dbt_assets, DbtCliResource
from ..project import dbt_project
@dbt_assets(
manifest=dbt_project.manifest_path,
)
def dbt_analytics(context: AssetExecutionContext, dbt: DbtCliResource):
yield from dbt.cli(["run"], context=context).stream()
Dagster version
dagster, version 1.7.0
What's the issue?
The custom schema setting in dbt is not working in dagster. Having a postgres materialization I would like that data is pushed into different database schemas. For this I am using the custom schema approach with a config inside the dbt model:
_mymodel.sql
schema.yml
Using the
dbt run
command creates the table in the schemamy_custom_schema
. In dagster I then use a job by selecting every downstream models ofmy_model
:jobs.py
Without the above
config()
setting in the dbt model I can start dagster normally usingdagster dev
and the model is also materialized when I run the job. But when adding theconfig()
block to my dbt model, I am getting the following error trace:What did you expect to happen?
I expect that dagster handles dbt's custom schema as described by dbt's documentation, creating a new database schema based on the name in the model's
config()
setting.How to reproduce?
No response
Deployment type
Local
Deployment details
No response
Additional information
No response
Message from the maintainers
Impacted by this issue? Give it a 👍! We factor engagement into prioritization.