Im trying to implement this: <https://www.elementa...
# community-support
m
Im trying to implement this: https://www.elementary-data.com/post/dbt-observability-101-how-to-monitor-dbt-run-and-test-results But at the end of a run i get:
20:28:43  on-run-end failed, error:
20:28:43   dbt was unable to infer all dependencies for the model "actiefwerk_dbt-on-run-end-0".
20:28:43  This typically happens when ref() is placed within a conditional block.
20:28:43
20:28:43  To fix this, add the following hint to the top of the model "actiefwerk_dbt-on-run-end-0":
20:28:43
20:28:43  -- depends_on: {{ ref('dbt_results') }}
While 'ofcourse' the --depends on is present like in the example.
e
Hi @Marco de Nijs, Unfortunately It's a little hard to troubleshoot this as the issue could be related to your dbt project. However I highly recommend trying our dbt package, you can find the instructions here :)
m
Related to my project? I litteraly copy pasted the example. And its only the on-run-end hook that fails. Not my model itself.
o
Hi macro! chiming in her to help with this. To help here we need more details from your project - could you please share your
dbt_project.yml
and
dbt.log
? Regardless, what Ella meant is that you can save all the trouble and time by just downloading our dbt package as it does this already (and much more) and it's much more battle tested (was tested across all platforms and many different dbt versions for example). Is there any reason why you don't want to go down that path?
m
Heya @Or Avidov of course. I have attached them here. On the part of installing the package: there is a stricter policy on installing packages here. I wanted to show my team the results of this small test to convince them we need something like Elementary would be really nice to have.
Dbt project:
# Name your project! Project names should contain only lowercase characters
# and underscores. A good package name should reflect your organization's
# name or the intended use of these models
name: 'actiefwerk_dbt'
version: '1.0.0'
config-version: 2
vars:
dbt_date:time_zone: "Europe/Amsterdam"
# This setting configures which "profile" dbt uses for this project.
profile: 'default'
# These configurations specify where dbt should look for different types of files.
`# The
source-paths
config, for example, states that models in this project can be`
# found in the "models/" directory. You probably won't need to change these!
model-paths: ["models"]
analysis-paths: ["analyses"]
test-paths: ["tests"]
seed-paths: ["seeds"]
macro-paths: ["macros"]
snapshot-paths: ["snapshots"]
target-path: "target"  # directory which will store compiled SQL files
`clean-targets: # directories to be removed by `dbt clean``
- "target"
- "dbt_packages"
quoting:
database: false
schema: false
identifier: false
# Configuring models
# Full documentation: <https://docs.getdbt.com/docs/configuring-models>
models:
actiefwerk_dbt:
staging:
+materialized: view
+database: "{{ env_var('DBT_STAGING') }}"
dwh:
+materialized: table
+database: "{{ env_var('DBT_DWH') }}"
on-run-end:
- "{{ log_dbt_results(results) }}"
o
Hi @Marco de Nijs, seems there is a little issue with the example in this blog post - the
ref
function is not available in
on-run-end
hooks drop sad You have two solutions: • if this is strictly for poc reasons, you can just reference it explicitly - (
database.schema.dbt_results
instead of
{{ ref('dbt_results' }}
) • if not, you can write a macro to find the "ref" of this model, you can see how we do it in our package here either way, remove the
--depends-on
comment from your
log_dbt_results
macro
m
Thanks! That did fix it indeed šŸ™‚
o
Awesome šŸ˜Ž