Open KLarrabee-Arcadia opened 6 months ago
Thanks for raising this issue @KLarrabee-Arcadia.
To help narrow down the issue, could you try out this "hello world" example to see if it works for you?
models/hello_world.sql
select 'world' as hello
models/_properties.yml
unit_tests:
- name: test_hello_world
model: hello_world
given: []
expect:
rows:
- {hello: world}
Run this command to execute the unit tests and then build the model if they pass:
dbt build --select hello_world
Thanks for responding @dbeatty10! I just added it and see the same error:
❯ docker compose run dbt dbt build --select hello_world
WARN[0000] /Users/kevinlarrabee/projects/dbt-unit-test-example/docker-compose.yml: `version` is obsolete
18:33:27 Running with dbt=1.8.0
18:33:27 Registered adapter: spark=1.8.0
18:33:27 [WARNING]: Configuration paths exist in your dbt_project.yml file which do not apply to any resources.
There are 1 unused configuration paths:
- models.int_customers_per_store
18:33:27 Found 3 models, 8 data tests, 453 macros, 3 unit tests
18:33:27
18:33:32 Concurrency: 1 threads (target='dev')
18:33:32
18:33:32 1 of 2 START unit_test hello_world::test_hello_world ........................... [RUN]
18:33:37 1 of 2 ERROR hello_world::test_hello_world ..................................... [ERROR in 5.11s]
18:33:37 2 of 2 SKIP relation hudi_dbt.hello_world ...................................... [SKIP]
18:33:43
18:33:43 Finished running 1 unit test, 1 view model in 0 hours 0 minutes and 15.35 seconds (15.35s).
18:33:43
18:33:43 Completed with 1 error and 0 warnings:
18:33:43
18:33:43 Runtime Error in unit_test test_hello_world (models/_properties.yml)
An error occurred during execution of unit test 'test_hello_world'. There may be an error in the unit test definition: check the data types.
Compilation Error
'NoneType' object is not iterable
> in macro run_query (macros/etc/statement.sql)
> called by macro materialization_unit_default (macros/materializations/tests/unit.sql)
> called by <Unknown>
18:33:43
18:33:43 Done. PASS=0 WARN=0 ERROR=1 SKIP=1 TOTAL=2
@dbeatty10 I also set up a different branch in that example repo that has two different Spark backends, one configured for Hudi and one with a default configuration, as well as a Postgre backend.
Running dbt test
shows the same NoneType
error as reported against either of the Spark backends, but (as a sanity check) it does work against the Postgres backend:
$ docker compose run --build dbt dbt test --target postgres
...
17:38:35 8 of 11 PASS unique_professors_name ............................................ [PASS in 5.05s]
17:38:35 9 of 11 START unit_test characters::test_characters ............................ [RUN]
17:38:35 9 of 11 FAIL 1 characters::test_characters ..................................... [FAIL 1 in 0.07s]
17:38:35 10 of 11 START unit_test hello_world::test_hello_world ......................... [RUN]
17:38:35 10 of 11 PASS hello_world::test_hello_world .................................... [PASS in 0.02s]
17:38:35 11 of 11 START unit_test professors::test_professors ........................... [RUN]
17:38:35 11 of 11 ERROR professors::test_professors ..................................... [ERROR in 0.02s]
17:38:35
17:38:35 Finished running 8 data tests, 3 unit tests in 0 hours 0 minutes and 10.44 seconds (10.44s).
17:38:35
17:38:35 Completed with 2 errors and 0 warnings:
17:38:35
17:38:35 Failure in unit_test test_characters (models/unit_tests/test_characters.yml)
17:38:35
actual differs from expected:
@@ ,id,name
→ ,1 ,kevin→Philip J. Fry
+++,2 ,Turanga Leela
+++,3 ,Bender Bending Rodríguez
+++,4 ,Prof. Hubert J. Farnsworth
+++,5 ,Professor Ogden Wernstrom
Is this a new bug in dbt-core?
Current Behavior
We are attempting to run DBT unit tests against a local dockerized Spark/Hudi container, and while
dbt run
is perfectly successful, we cannot for the life of us getdbt test
to work properly despite following docs and searching through issues. Anything we do (assuming the test spec is valid - otherwise we appropriately get hints like "need given", etc) just results in'NoneType' object is not iterable
errors:One of my coworkers was successfully running the unit tests against DuckDB, so we assumed the test specs were fine.
Expected Behavior
The test should pass/fail rather than error out.
Steps To Reproduce
I created a very simple repository where (1)
dbt run
is successful and (2)dbt test
results in the error above (see repo README for steps to reproduce success and failure).Relevant log output
After locally adding
import traceback; print(traceback.format_exc())
right before this line I observed the following stack trace:Is there some configuration that I missed for unit tests that is making this fail via PyHive, Thrift, etc?
When I look at the compiled SQL for the unit tests in the
targets/
folder, it does indeed create valid SQL that, when I run manually inbeeline
, returns expected results.Environment
Which database adapter are you using with dbt?
spark
Additional Context
This is specific to unit tests, since data tests run perfectly fine.