You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/concepts/tests.md
+29-27Lines changed: 29 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -60,32 +60,7 @@ The `rows` key is optional in the above format, so the following would also be v
60
60
...
61
61
```
62
62
63
-
### Omitting Columns
64
-
65
-
Defining the complete inputs and outputs for wide tables, i.e. tables with many columns, can become cumbersome. Therefore, if certain columns can be safely ignored they may be omitted from any row and their value will be treated as `NULL` for that row.
66
-
67
-
Additionally, it's possible to test only a subset of the output columns by setting `partial` to `true` for the rows of interest:
68
-
69
-
```yaml linenums="1"
70
-
...
71
-
outputs:
72
-
query:
73
-
partial: true
74
-
rows:
75
-
- <column_name>: <column_value>
76
-
...
77
-
```
78
-
79
-
This is useful when we can't treat the missing columns as `NULL`, but still want to ignore them. In order to apply this setting to _all_ outputs, simply set it under the `outputs` key:
80
-
81
-
```yaml linenums="1"
82
-
...
83
-
outputs:
84
-
partial: true
85
-
...
86
-
```
87
-
88
-
When `partial` is set for a _specific_ output, its rows need to be defined as a mapping under the `rows` key and only the columns referenced in them will be tested.
63
+
Note: the columns in each row of an expected output must appear in the same relative order as they are selected in the corresponding query.
89
64
90
65
### Example
91
66
@@ -155,7 +130,7 @@ test_example_full_model:
155
130
- num_orders: 3
156
131
```
157
132
158
-
Since [omitted columns](#omitting-columns) are treated as `NULL`, this test also implicitly asserts that both the input and the output `item_id` columns are `NULL`, which is correct.
133
+
Since [omitted columns](#omitting-columns) are treated as `NULL`, this test also implicitly asserts that both the input and the expected output `item_id` columns are `NULL`, which is correct.
159
134
160
135
### Testing CTEs
161
136
@@ -210,6 +185,33 @@ test_example_full_model:
210
185
num_orders: 2
211
186
```
212
187
188
+
### Omitting Columns
189
+
190
+
Defining the complete inputs and expected outputs for wide tables, i.e. tables with many columns, can become cumbersome. Therefore, if certain columns can be safely ignored they may be omitted from any row and their value will be treated as `NULL` for that row.
191
+
192
+
Additionally, it's possible to test only a subset of the expected output columns by setting `partial` to `true` for the rows of interest:
193
+
194
+
```yaml linenums="1"
195
+
...
196
+
outputs:
197
+
query:
198
+
partial: true
199
+
rows:
200
+
- <column_name>: <column_value>
201
+
...
202
+
```
203
+
204
+
This is useful when we can't treat the missing columns as `NULL`, but still want to ignore them. In order to apply this setting to _all_ expected outputs, simply set it under the `outputs` key:
205
+
206
+
```yaml linenums="1"
207
+
...
208
+
outputs:
209
+
partial: true
210
+
...
211
+
```
212
+
213
+
When `partial` is set for a _specific_ expected output, its rows need to be defined as a mapping under the `rows` key and only the columns referenced in them will be tested.
214
+
213
215
### Freezing Time
214
216
215
217
Some models may use SQL expressions that compute datetime values at a given point in time, such as `CURRENT_TIMESTAMP`. Since these expressions are non-deterministic, it's not enough to simply specify an expected output value in order to test them.
0 commit comments