-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
0.19.1 unable to infer dependencies for custom tests #3229
Comments
@bmwilly Thanks for the report! It does look like this represents a regression from v0.19.0. Could you clarify what If this represents a different model that is being directly referenced from within your schema test definition, then I've been able to reproduce this error: {% macro test_valid_code(model) %}
select count(*) from (
select * from {{ model }}
union all
select * from {{ ref('model_b') }}
)
{% endmacro %} Compilation Error in test valid_code_model_a_ (models/schema.yml)
dbt was unable to infer all dependencies for the model "valid_code_model_a_".
This typically happens when ref() is placed within a conditional block.
To fix this, add the following hint to the top of the model "valid_code_model_a_":
-- depends_on: {{ ref('model_b') }}
> in macro test_valid_code (macros/test_valid_code.sql)
> called by test valid_code_model_a_ (models/schema.yml)
> called by test valid_code_model_a_ (models/schema.yml) Here's one way to work around this in the meantime, so that the dependency is still detected: {% macro test_valid_code(model, other_model) %}
select count(*) from (
select * from {{ model }}
union all
select * from {{ other_model }}
) validation_errors
{% endmacro %} version: 2
models:
- name: model_a
tests:
- valid_code:
other_model: "{{ ref('model_b') }}" The latter construction is what I'd recommend for generic/schema tests, anyhow. That said, we'll investigate and see if we can figure a way to restore the previous behavior. |
@jtcohen6 thanks for the quick response and for the understanding from my not very clear report!
yes, I did mean a different model that is being directly referenced in the schema test definition, similar to the example you give. I was able to fix this using your workaround — thanks! Feel free to close this issue; I'll leave it open in case you want to use it to track restoring the previous functionality. |
@bmwilly We're including a fix for this in v0.19.2, for which we just cut a release candidate. Any chance you could test locally and confirm that it fixes the issue you described above? pip install dbt==0.19.2rc1
# or
brew install [email protected] |
@jtcohen6 seems to work, thanks! |
@jtcohen6 works if the test is in the same package, but apparently still fails with tests from another package. |
Thanks for the report @MartinNowak! I wonder if you're seeing the same error as the one reported over in #3324? |
Thx for reproducing and appending, indeed it's sth. in between the two problems. |
issue: dbt-labs/dbt-core#3229 solution: given by dbt cli when error
* dbt.model.new: df1_indic et df1_ch Ajout de ces models pour changer facilement les tables d'exposition (indicateur et chantier) * dbt.model.new: df1_indic et df1_ch Ajout de ces models pour changer facilement les tables d'exposition (indicateur et chantier) * fix empty array * fix: directions_administration_centrale on récupère correctement les directions_administration_centrale à l'aide de la table metadata_porteur et non plus dans la colonne porteur_shorts_DAC de metadata_chantier qui était présente pour information donc sur laquelle il ne faut pas se baser. * replace dy dbt ref * dbt.model.new: df1_indic et df1_ch Ajout de ces models pour changer facilement les tables d'exposition (indicateur et chantier) * fix empty array * fix: directions_administration_centrale on récupère correctement les directions_administration_centrale à l'aide de la table metadata_porteur et non plus dans la colonne porteur_shorts_DAC de metadata_chantier qui était présente pour information donc sur laquelle il ne faut pas se baser. * replace dy dbt ref * update dbt tests * fix tests issue: dbt-labs/dbt-core#3229 solution: given by dbt cli when error
* dbt.model.new: df1_indic et df1_ch Ajout de ces models pour changer facilement les tables d'exposition (indicateur et chantier) * dbt.model.new: df1_indic et df1_ch Ajout de ces models pour changer facilement les tables d'exposition (indicateur et chantier) * fix empty array * fix: directions_administration_centrale on récupère correctement les directions_administration_centrale à l'aide de la table metadata_porteur et non plus dans la colonne porteur_shorts_DAC de metadata_chantier qui était présente pour information donc sur laquelle il ne faut pas se baser. * replace dy dbt ref * dbt.model.new: df1_indic et df1_ch Ajout de ces models pour changer facilement les tables d'exposition (indicateur et chantier) * fix empty array * fix: directions_administration_centrale on récupère correctement les directions_administration_centrale à l'aide de la table metadata_porteur et non plus dans la colonne porteur_shorts_DAC de metadata_chantier qui était présente pour information donc sur laquelle il ne faut pas se baser. * replace dy dbt ref * update dbt tests * fix tests issue: dbt-labs/dbt-core#3229 solution: given by dbt cli when error
* fix directeurs_administration_centrale on corrige directeurs_administration_centrale fix directeurs_administration_centrale (2) * Cohabitation df1-df3 + fix df3_chantier (#671) * dbt.model.new: df1_indic et df1_ch Ajout de ces models pour changer facilement les tables d'exposition (indicateur et chantier) * dbt.model.new: df1_indic et df1_ch Ajout de ces models pour changer facilement les tables d'exposition (indicateur et chantier) * fix empty array * fix: directions_administration_centrale on récupère correctement les directions_administration_centrale à l'aide de la table metadata_porteur et non plus dans la colonne porteur_shorts_DAC de metadata_chantier qui était présente pour information donc sur laquelle il ne faut pas se baser. * replace dy dbt ref * dbt.model.new: df1_indic et df1_ch Ajout de ces models pour changer facilement les tables d'exposition (indicateur et chantier) * fix empty array * fix: directions_administration_centrale on récupère correctement les directions_administration_centrale à l'aide de la table metadata_porteur et non plus dans la colonne porteur_shorts_DAC de metadata_chantier qui était présente pour information donc sur laquelle il ne faut pas se baser. * replace dy dbt ref * update dbt tests * fix tests issue: dbt-labs/dbt-core#3229 solution: given by dbt cli when error * hotfix: Revert "feat: ajout de la météo dans import massif de commentaires (000)" This reverts commit 526bfc6. * compare ta_ch et ta_indic * compute_ta_indic: add 2 rules 2 rules: - si hausse et va>=vc -> 100% - si baisse et va<=vc -> 100% * fix: handle ta=nouveau_ta then ratio will be 0 * update dump scripts * Update .gitignore * Update README.md * update migration process
Describe the bug
I have a macro
test_valid_code
defining a custom test that uses{{ ref('model') }}
. For dbt 0.19.1 (this only fails for 0.19.1),dbt compile
givesTrying to add
-- depends_on: {{ ref('model') }}
to the model and/or test file doesn't help.Expected behavior
dbt {compile,run}
to not give any errors.System information
Which database are you using dbt with?
The output of
dbt --version
:The operating system you're using:
macOS 11.2.3
The output of
python --version
:Python 3.8.5
The text was updated successfully, but these errors were encountered: