Closed mairamelo26 closed 2 weeks ago
Did you provide your own version for the variable primary_key_test_macros
and if so, could you please what you provided?
Hi @b-per thanks for your reply. I've included this in my dbt_project.yml under "vars":
vars:
dbt_project_evaluator:
enforced_primary_key_node_types:
- model
- snapshot
- seed
primary_key_test_macros:
- dbt_utils.unique_combination_of_columns
- dbt_utils.not_null
primary_key_test_macros
should be a list of list and not just a list
Can you try one of the below:
primary_key_test_macros:
-
- "dbt_utils.unique_combination_of_columns"
- "dbt_utils.not_null"
or
primary_key_test_macros:
- ["dbt_utils.unique_combination_of_columns", "dbt_utils.not_null"]
Which should be equivalent
Sure! Let's try
Hi @b-per ,
Ok something funny seems to be happening. This is the error that I get when I run the dbt build command again.
This is the command that I run: dbt build --select package:dbt_project_evaluator dbt_project_evaluator_exceptions
And this is the error I got just now:
1:45:19 37 of 62 ERROR creating sql view model dbt_project_evaluator.fct_missing_primary_key_tests [ERROR in 4.21s]
[...]
11:46:03 Database Error in model fct_missing_primary_key_tests (models/marts/tests/fct_missing_primary_key_tests.sql)
syntax error at or near "model" in context "resource_type in
(
'['model", at line 11, column 12
compiled code at target/run/dbt_project_evaluator/models/marts/tests/fct_missing_primary_key_tests.sql
11:46:03
This is the DDL of the view before running the command:
CREATE OR REPLACE VIEW fct_missing_primary_key_test
AS SELECT final.resource_name, final.resource_type, final."model_type", final.is_primary_key_tested, final.number_of_tests_on_model, final.number_of_constraints_on_model
FROM ( SELECT tests.resource_name, tests.resource_type, tests."model_type", tests.is_primary_key_tested, tests.number_of_tests_on_model, tests.number_of_constraints_on_model
FROM ( SELECT int_model_test_summary.resource_name, int_model_test_summary.resource_type, int_model_test_summary."model_type", int_model_test_summary.is_primary_key_tested, int_model_test_summary.number_of_tests_on_model, int_model_test_summary.number_of_constraints_on_model
FROM dbt_project_evaluator.int_model_test_summary
WHERE int_model_test_summary.resource_type::text = 'model'::text) tests
WHERE NOT tests.is_primary_key_tested) final;
This is after:
CREATE OR REPLACE VIEW fct_missing_primary_key_test
AS Not a view;
What could be happening?
There were some mistakes that I needed to fix to stop having the create table error:
Mistake 1:
The documentation says that the seed dbt_project_evaluator_exceptions
inside dbt_project.yml
should be set as false, but in fact that prevents the build command to run. So I changed to True.
Mistake 2: I believe that the seed documentation could include some more examples so we can maybe be able to better create it ourselves according to our needs. In my case it was a source table that needed to be excluded from the fct_missing_primary_key_test. Maybe whoever gets this on their search learns from this mistake on how not to create the seed properly.
Mistake 3:
Fixing column values inside the exception seed, especially the:
fct_name:
The actual fact table is the actual rule that we want the exception do be placed. The only possible values here are listed inside the rule list. Which in my case was "fct_missing_primary_key_tests"
Mistake 4:
Removed the new entries in the dbt_project.yml
where I added the lines in the "vars" section related to "enforced_primary_key_node_types" and "primary_key_test_macros".
Now what is happening is that the source table that I wished to exclude stills shows up causing the test error "is_empty_fct_missing_primary_keytests" even with all the steps covered and double checked. I wonder if fct_missing_primary_key_test
can be used in the dbt_project_evaluator_exceptions.csv
seed ?
Anyway the main "failure" is solved by fixing those mistakes, therefore the ticket can be closed. Thank you
Describe the bug
I am using this documentation in order to setup an exception for a source table that I wish not to have a primary_key_missing test. However after doing that and running the following command:
dbt build --select package:dbt_project_evaluator dbt_project_evaluator_exceptions
I guet this error in the logs and I can't bypass that:
I have all the dependencies up to date and the only alteration I've made is what is instructed in the documentation "Configuring exceptions to the rules" mentioned above.
Steps to reproduce
I have two new directories in my repository (under the root of the project):
Inside testing.yml I have:
Inside exceptions.csv there's:
And I also updated dbt_project.yml with this:
And then I run the command below:
dbt build --select package:dbt_project_evaluator dbt_project_evaluator_exceptions
Expected results
I was hoping that the output would be without errors.
Actual results
I actually get the error below:
Screenshots and log output
Paste above
System information
The contents of your
packages.yml
file:Which database are you using dbt with?
The output of
dbt --version
:Additional context
Not at this moment
Are you interested in contributing the fix?
Yes please