Skip to content

Commit

Permalink
Merge pull request #143 from dbt-labs/dc/add-sql-as-unit-test-format
Browse files Browse the repository at this point in the history
add sql as approved unit test format
  • Loading branch information
dave-connors-3 authored May 23, 2024
2 parents 3566dcb + ebd80f9 commit c36a473
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
8 changes: 5 additions & 3 deletions schemas/latest/dbt_yml_files-latest.json
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,7 @@
"else": {
"properties": {
"rows": {
"description": "When `format` is csv, a string containing comma-separated headers and values. Alternatively provide a fixture. Use the pipe character | to create a multi-line string in YAML.",
"description": "When `format` is csv or sql, a string containing comma-separated headers and values. Alternatively provide a fixture. Use the pipe character | to create a multi-line string in YAML.",
"type": "string"
}
}
Expand All @@ -920,6 +920,7 @@
"type": "string",
"enum": [
"dict",
"sql",
"csv"
]
},
Expand Down Expand Up @@ -951,7 +952,7 @@
"else": {
"properties": {
"rows": {
"description": "When `format` is csv, a string containing comma-separated headers and values. Alternatively provide a fixture. Use the pipe character | to create a multi-line string in YAML.",
"description": "When `format` is csv or sql, a string containing comma-separated headers and values. Alternatively provide a fixture. Use the pipe character | to create a multi-line string in YAML.",
"type": "string"
}
}
Expand All @@ -966,7 +967,8 @@
"type": "string",
"enum": [
"dict",
"csv"
"csv",
"sql"
]
},
"input": {
Expand Down
20 changes: 20 additions & 0 deletions tests/latest/valid/dbt_yml_files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,26 @@ unit_tests:
count
2
- name: my_sql_unit_test
model: unit_reworked_compare_struct
given:
- input: ref('unit_test_struct_model_a')
format: sql
rows: |
select 1 as id, 'John Doe' as col1, object_construct('street', '123 Main St', 'city', 'Anytown', 'state', 'CA') as col2
- input: ref('unit_test_struct_model_b')
format: sql
rows: |
select 1 as id, 'John Doe' as col1, object_construct('street', '123 Main St', 'city', 'Anytown', 'state', 'CA') as col2
expect:
rows:
- {"id": 1, "dbt_audit_row_status": "identical", "dbt_audit_num_rows_in_status": 1}
overrides:
vars:
reworked_compare__columns: ['id', 'col1', 'col2']
reworked_compare__event_time:
reworked_compare__primary_key_columns: ['id']

snapshots:
- name: snapshot_name
group: analytics
Expand Down

0 comments on commit c36a473

Please sign in to comment.