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

[Bug] Re-open dbt unit test does not work without external package #11083

Closed
2 tasks done
sangee14 opened this issue Dec 2, 2024 · 2 comments
Closed
2 tasks done

[Bug] Re-open dbt unit test does not work without external package #11083

sangee14 opened this issue Dec 2, 2024 · 2 comments
Labels
awaiting_response bug Something isn't working wontfix Not a bug or out of scope for dbt-core

Comments

@sangee14
Copy link

sangee14 commented Dec 2, 2024

Is this a new bug in dbt-core?

  • I believe this is a new bug in dbt-core
  • I have searched the existing issues, and I could not find an existing issue for this bug

Current Behavior

I am trying to implement dbt unit tests without using any of the external package being installed. But the native dbt unit tests does not work and while executing it using the command dbt test --select test_name , it just not picking up the test and executing it. It says, the selection criterion does not match any node.

Expected Behavior

The test should be get picked up and executed successfully against the model using the dbt test command

Steps To Reproduce

# tests/test_properties.yml

unit_tests:
  - name: current_student_view_data
    description: "stores students data"
    model: curr_raw_student_view
    given:
    - input: ref('hub_raw_student')
      rows:
        - {student_users_pk: '83E71047', student_id: '3063542d005f'}
 
    - input: ref('sat_raw_student_details')
      rows:
        - {student_users_pk: '83E71047', student_id: '3063542d005f', email: '[email protected]', first_name: 'Hello1', last_name: 'Guest'}
   
    expect:
      rows:
        - {student_id: '3063542d005f', email: '[email protected]', first_name: 'Hello1', last_name: 'Guest'}

Run: dbt test --select current_student_view_data
Outcome:

root@**********:/usr/app/dbt# dbt test --select current_ajo_view_data
06:54:23  Running with dbt=1.7.3
06:54:24  Registered adapter: snowflake=1.7.1
06:54:34  Found 67 models, 1 snapshot, 5 tests, 87 sources, 0 exposures, 0 metrics, 1017 macros, 0 groups, 0 semantic models
06:54:34  The selection criterion 'current_student_view_data' does not match any nodes
06:54:34
06:54:34  Nothing to do. Try checking your model configs and model specification args

Relevant log output

root@**********:/usr/app/dbt# dbt test --select current_ajo_view_data
06:54:23  Running with dbt=1.7.3
06:54:24  Registered adapter: snowflake=1.7.1
06:54:34  Found 67 models, 1 snapshot, 5 tests, 87 sources, 0 exposures, 0 metrics, 1017 macros, 0 groups, 0 semantic models
06:54:34  The selection criterion 'current_student_view_data' does not match any nodes
06:54:34
06:54:34  Nothing to do. Try checking your model configs and model specification args

Environment

- OS: Windows 10
- Python:
- dbt-core:1.8.9
- dbt-snowflake: 1.8.3

Which database adapter are you using with dbt?

snowflake

Additional Context

No response

@sangee14 sangee14 added bug Something isn't working triage labels Dec 2, 2024
@gshank
Copy link
Contributor

gshank commented Dec 2, 2024

--select without specifying what you're selecting, implies "model". You don't have a "current_student_view_data" model. Try using the model name "curr_raw_student_view", or use a selector that specifies the unit test in some way.

@gshank gshank closed this as completed Dec 2, 2024
@dbeatty10 dbeatty10 closed this as not planned Won't fix, can't repro, duplicate, stale Dec 3, 2024
@dbeatty10 dbeatty10 added wontfix Not a bug or out of scope for dbt-core and removed triage labels Dec 3, 2024
@dbeatty10
Copy link
Contributor

@sangee14 Could you move your YAML file containing your unit test(s) from the tests directory into the models directory and try your command again?

More detail

When you execute dbt list, you should get a row like this:

unit_test:my_project.current_student_view_data

But if you don't see that when you run dbt list, it means that dbt isn't picking up your YAML file that has your unit tests. I think that is what is happening here.

After moving it to the models directory, then I think you will get output like this:

$ dbt list                               
00:11:42  Running with dbt=1.8.8

my_project.curr_raw_student_view
unit_test:my_project.current_student_view_data

$ dbt test --select current_student_view_data               
00:12:14  Running with dbt=1.8.8
00:12:14  Found 1 model, 410 macros, 1 unit test
00:12:14  
00:12:14  1 of 1 START unit_test curr_raw_student_view::current_student_view_data ........ [RUN]
00:12:14  1 of 1 PASS curr_raw_student_view::current_student_view_data ................... [PASS in 0.16s]
00:12:15  
00:12:15  Finished running 1 unit test in 0 hours 0 minutes and 0.33 seconds (0.33s).
00:12:15  
00:12:15  Completed successfully
00:12:15  
00:12:15  Done. PASS=1 WARN=0 ERROR=0 SKIP=0 TOTAL=1

Follow-up feature request

I've opened this feature request to allow unit tests to be defined in the tests directory in addition to the models directory: #11093

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting_response bug Something isn't working wontfix Not a bug or out of scope for dbt-core
Projects
None yet
Development

No branches or pull requests

3 participants