Comments (5)
Here's some minimal reproducible examples using dbt-postgres:
Reprex
models/my_input_model.sql
select 1 as id, 'some string' as status
models/my_model.sql
select * from {{ ref("my_input_model") }}
models/unit_tests.yml
unit_tests:
# ❌
- name: unexpected_test_1
model: my_model
given:
- input: ref("my_input_model")
rows:
- {"id": , "status": 'B'}
- {"id": , "status": 'B'}
- {"id": 3, "status": 'A'}
expect:
rows:
- {"id": 3, "status": 'A'}
- {"id": , "status": 'B'}
- {"id": , "status": 'B'}
# ❌
- name: unexpected_test_2
model: my_model
given:
- input: ref("my_input_model")
rows:
- {"id": 3, "status": 'A'}
- {"id": , "status": 'B'}
- {"id": , "status": 'B'}
expect:
rows:
- {"id": , "status": 'B'}
- {"id": , "status": 'B'}
- {"id": 3, "status": 'A'}
# ✅
- name: expected_test_0
model: my_model
given:
- input: ref("my_input_model")
rows:
- {"id": 3, "status": 'A'}
- {"id": , "status": 'B'}
expect:
rows:
- {"id": , "status": 'B'}
- {"id": 3, "status": 'A'}
# ✅
- name: expected_test_1
model: my_model
given:
- input: ref("my_input_model")
rows:
- {"id": 3, "status": 'A'}
- {"id": , "status": 'B'}
- {"id": , "status": 'B'}
expect:
rows:
- {"id": 3, "status": 'A'}
- {"id": , "status": 'B'}
- {"id": , "status": 'B'}
# ✅
- name: expected_test_2
model: my_model
given:
- input: ref("my_input_model")
rows:
- {"id": , "status": 'B'}
- {"id": , "status": 'B'}
- {"id": 3, "status": 'A'}
expect:
rows:
- {"id": , "status": 'B'}
- {"id": , "status": 'B'}
- {"id": 3, "status": 'A'}
Run this command:
dbt build -s +my_model
from dbt-core.
Amusingly, I also believe that each adapter has different order needs! This test fails on Redshift but passes locally on Snowflake: https://app.circleci.com/pipelines/github/dbt-labs/dbt-audit-helper/416/workflows/64b0d0f6-8cd8-48cf-bac2-e462987d69fa/jobs/409 (and presumably vice versa, but I haven't 100% tested that)
from dbt-core.
Not sure if it is related or not, but in dbt-labs/dbt-redshift#821, the rows with non-null values also needed to come prior to the rows with nulls.
from dbt-core.
@joellabes Which database are you seeing this error in?
from dbt-core.
Notes from estimation:
- could be related to #9881 (but that's for csv, this one is independent of format)
- this is happening when there are multiple explicit NULL values in the expected output of a unit test
- different adapters have different order requirements
- alignment in daff ob/main/core/dbt/task/test.py#L338-L353
from dbt-core.
Related Issues (20)
- Add `--host` flag to `dbt docs serve`, defaulting to '127.0.0.1' HOT 2
- [Bug] `dbt -v` doesn't know that adapters are decoupled from core HOT 1
- Warn if `updated_at` field for snapshot is not same datatype (or timezone) as what's returned in `snapshot_get_time()` HOT 2
- Improve capturing the history of records in a deleted state HOT 2
- New snapshot config to validate uniqueness before merge
- Support specifying types for recording
- [Bug] the run_query macro causes unit tests to fail with a SQL Compilation error HOT 1
- [Feature] No more jinja block for snapshots - new snapshot design
- [Feature] Emit a more specific error when there are duplicate columns in a model with an enforced contract HOT 1
- Replace jsonschema with fastjsonschema for validation
- [Security] CVE-2019-8341 advice please HOT 5
- [Feature] Conservative with changing public Python API's HOT 1
- [Feature] Unit tests should support Gherkin table style inputs
- [Bug] Error running unit tests that use the `dbt_utils.star` macro HOT 2
- Create "happy path" project fixture and use it for `tests/functional/list/test_list.py`
- Use, and extend as necessary, happy path fixture for `tests/functional/show/test_show.py`
- [Bug] dbt test --select "source:*" runs model tests if they reference a source HOT 3
- [Feature] Add a head command to see the first rows of a table HOT 5
- [Feature] Add `--fail-if-nothing-selected` (or something similar) HOT 6
- [Bug] Not able to select unit tests via the `--resource-type` flag HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dbt-core.