Skip to content
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

schema tests in dependent projects #491

Closed
jthandy opened this issue Jul 16, 2017 · 2 comments
Closed

schema tests in dependent projects #491

jthandy opened this issue Jul 16, 2017 · 2 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@jthandy
Copy link
Member

jthandy commented Jul 16, 2017

@cmcarthur I've been using rewrite-materializations-1 and in general things have been working well. I was able to get my equality schema test up and running when I defined it in my local project. However, when I went to refactor it out into a shared utils project, it failed to run. Here are a bunch of details.

Console:

(venv) Tristans-MBP:analytics tristan$ dbt test --models table_a
Found 111 models, 122 tests, 0 archives, 0 analyses, 29 macros, 1 operations

16:05:01 | Concurrency: 4 threads (target='dev')
16:05:01 |
16:05:01 | 1 of 1 START test equality_table_a_ref_table_b_...................... [RUN]
16:05:01 | 1 of 1 ERROR equality_table_a_ref_table_b_........................... [ERROR in 0.01s]
! Compilation error while compiling test equality_table_a_ref_table_b_:
! 'test_equality' is undefined

Completed with 1 errors:
 - ERROR in test my_schema.equality_table_a_ref_table_b_ (None)

Done. PASS=0 ERROR=1 SKIP=0 TOTAL=1

Link to my utility repo:
https://github.com/fishtown-analytics/dbt-utils

I can't link you to the actual place where it's failing because I have it implemented in a branch of a client project and have the tests build out using their data, but I can show you tomorrow.

The strangest thing about this is that it's clear from looking at the logs that dbt can see that file! Look at this:

...
2017-07-16 16:09:12,457: Parsing schema_tests/unique.sql
2017-07-16 16:09:12,460: Parsing equality.sql
2017-07-16 16:09:12,467: Parsing url_query.sql
2017-07-16 16:09:12,506: Found 111 models, 122 tests, 0 archives, 0 analyses, 29 macros, 1 operations
...

I'm not sure why it's able to parse it but then it's not able to find it later.

/cc @drewbanin

@drewbanin
Copy link
Contributor

@jthandy unsure if this has changed in the new branch, but I believe you must scope the test name w/ the project name that it's defined in.

More info here: #339

This makes sense given that dbt parses the file, but it's not present in the scope.

@jthandy jthandy added the bug Something isn't working label Oct 12, 2017
@jthandy
Copy link
Member Author

jthandy commented Oct 12, 2017

Quick update: this is still broken. Just tested, with the following result:

Tristans-MacBook-Pro:analytics tristan$ dbt test --models model_a

13:43:37 | Concurrency: 4 threads (target='dev')
13:43:37 |
13:43:37 | 1 of 1 START test equality_model_a_ref_model_b_...................... [RUN]
13:43:37 | 1 of 1 ERROR equality_model_a_ref_model_b_........................... [ERROR in 0.01s]

Completed with 1 errors:

Compilation Error in test equality_model_a_ref_model_b_ (models/test/schema.yml)
  'test_equality' is undefined

The schema file looks like this:

model_a:
    constraints:
        dbt_utils.equality:
            - ref('model_b')

@jthandy jthandy added this to the 0.9.0 milestone Oct 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants