QuestionQ49

Verified

You define a new generic test on the customers model in a YAML file:

version: 2  
models:  
- name: customers columns:  
- name: customer_id tests:  
- unique  
- not_null  

The next time your project compiles, you receive this error:

Raw Error:  
mapping values are not allowed in this context in "<unicode string>", line 7, column 21  

What causes this error?

Explanation

In a dbt properties file, a column's tests are a YAML list under the tests key, and each list entry (unique, not_null) must be indented consistently relative to tests so the parser reads them as that key's sequence. A parser error of the form 'mapping values are not allowed in this context' means a line was read as a plain scalar followed by a stray colon, which is what happens when the tests key and its entries are not laid out on separate, correctly aligned lines. Of the offered fixes, only repairing the alignment of unique and not_null relative to tests addresses that. Tests are documented as a list (so A and C are wrong), and the key never needs quoting (B).

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!