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

dbt crashes when a test file contains >1 test and is named after a macro ('dict' object is not callable) #216

Open
alexzorin opened this issue Jun 5, 2024 · 2 comments

Comments

@alexzorin
Copy link
Contributor

Hello again!

I have included a simple proof-of-concept repository for this issue: https://github.com/alexzorin/dbt-unit-test-macro-crash-poc. You can clone it, run dbt deps and dbt build --full-refresh to observe the behavior.

What I have observed is when:

then dbt test will crash with the following error:

❯ dbt test
23:43:21  Running with dbt=1.8.2
23:43:22  Registered adapter: duckdb=1.8.1
23:43:22  Found 1 model, 3 data tests, 596 macros
23:43:22  
23:43:22  Concurrency: 1 threads (target='dev')
23:43:22  
23:43:22  1 of 3 START test example_macro ................................................ [RUN]
23:43:22  1 of 3 ERROR example_macro ..................................................... [ERROR in 0.07s]
23:43:22  2 of 3 START test not_null_my_first_dbt_model_id ............................... [RUN]
23:43:22  2 of 3 PASS not_null_my_first_dbt_model_id ..................................... [PASS in 0.02s]
23:43:22  3 of 3 START test unique_my_first_dbt_model_id ................................. [RUN]
23:43:22  3 of 3 PASS unique_my_first_dbt_model_id ....................................... [PASS in 0.01s]
23:43:22  
23:43:22  Finished running 3 data tests in 0 hours 0 minutes and 0.16 seconds (0.16s).
23:43:22  
23:43:22  Completed with 1 error and 0 warnings:
23:43:22  
23:43:22    Compilation Error in test example_macro (tests/example_macro.sql)
  'dict' object is not callable
  
  > in macro build_model_complete_sql (macros/sql_builders.sql)
  > called by macro build_test_queries (macros/tests.sql)
  > called by macro build_configuration_and_test_queries (macros/tests.sql)
  > called by macro test (macros/tests.sql)
  > called by test example_macro (tests/example_macro.sql)
23:43:22  
23:43:22  Done. PASS=2 WARN=0 ERROR=1 SKIP=0 TOTAL=3

It is possible to work around the issue by:

  • Naming the file literally anything else (like adding a .test.sql suffix), or
  • Only having a single test in the file.

You can try those workarounds in the sample repo.

We are (indirectly) using this package for testing of macros as well as models, and it would be really helpful to not have this constraint around naming, naming convention helps us track test coverage.

Thank you once again!

@shellyYG
Copy link
Contributor

shellyYG commented Jun 6, 2024

Vote for this, having same issue too

@psousa50
Copy link
Collaborator

psousa50 commented Aug 9, 2024

Hi all,

sorry for the late response 😞

I'm a bit short of time right now but if you are still experiencing this issue I can take a look

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants