Emir Karamehmetoglu
03/28/2023, 11:18 PMdbt tests
as bona-fide Dagster Assets. We've thought about it and they seem ideal as assets, with a catch. I want them to materialize the test result on failure (ignore_handled_error
in dbt_resource
works for this). But currently tests are hard coded in dagster_dbt
to not be assets, and my hacky workarounds have short-comings 😛.
But it is really nice to be able to put tests, which are really just sql models like dbt, into an asset lineage graph, see the dependencies, assign freshness policies and have a reconciliation sensor handle it all, plus the occasional asset job for batch tests.Stephen Bailey
03/29/2023, 2:52 PMAssetObservation
events, which seems to me the right approach conceptually. The problem you get with tests is that you usually have more than 1 test per model, which means you'll quickly obliterate your asset graph's intelligibility.
Have you tried using dbt build
instead of dbt run
to materialize your models? Then you are basically lumping all your model sql (test + model) into the same asset, which sounds like what you are aiming for.Emir Karamehmetoglu
03/29/2023, 3:10 PMStephen Bailey
03/29/2023, 3:55 PMload_assets_from_dbt_project
• job-level assets are jobs of dbt run --select x.y.z
and dbt test --select x.y.z
so we have schedules/sensors that run all the job-level assets on their expected cadence, and we build the dependency graph on that. our dbt project is layered, so it basically amounts to
run_layer_1_job = `dbt run --select layer_1`
test_layer_1_job = `dbt test --select layer_1` #downstream of layer 1
run_layer_2_job = `dbt run --select layer_2` # downstream of layer 1
test_layer_2_job = `dbt test --select layer_2` #downstream of layer 2
run_layer_3_job = `dbt run --select layer_3` # downstream of layer 2
...
Stephen Bailey
03/29/2023, 3:55 PMEmir Karamehmetoglu
03/30/2023, 7:19 AMEmir Karamehmetoglu
04/03/2023, 7:22 AM