-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CT-1959]: moving simple_seed tests to adapter zone #6859
Merged
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
37bf2dd
Formatting
nssalian e5ad8cd
Changelog entry
nssalian eb7d4a6
Rename to BaseSimpleSeedColumnOverride
nssalian b97fae7
Better error handling
nssalian 8301c1f
Update test to include the BOM test
nssalian 1ef7a6c
Cleanup and formating
nssalian 84dffa6
Unused import remove
nssalian c38540a
nit line
nssalian bdc7a43
Pr comments
nssalian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: Under the Hood | ||
body: Moving simple_seed to adapter zone to help adapter test conversions | ||
time: 2023-02-03T14:35:51.481856-08:00 | ||
custom: | ||
Author: nssalian | ||
Issue: CT-1959 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
# | ||
# Macros | ||
# | ||
|
||
macros__schema_test = """ | ||
{% test column_type(model, column_name, type) %} | ||
|
||
{% set cols = adapter.get_columns_in_relation(model) %} | ||
|
||
{% set col_types = {} %} | ||
{% for col in cols %} | ||
{% do col_types.update({col.name: col.data_type}) %} | ||
{% endfor %} | ||
|
||
{% set validation_message = 'Got a column type of ' ~ col_types.get(column_name) ~ ', expected ' ~ type %} | ||
|
||
{% set val = 0 if col_types.get(column_name) == type else 1 %} | ||
{% if val == 1 and execute %} | ||
{{ log(validation_message, info=True) }} | ||
{% endif %} | ||
|
||
select '{{ validation_message }}' as validation_error | ||
from (select true) as nothing | ||
where {{ val }} = 1 | ||
|
||
{% endtest %} | ||
|
||
""" | ||
|
||
# | ||
# Models | ||
# | ||
|
||
models__downstream_from_seed_actual = """ | ||
select * from {{ ref('seed_actual') }} | ||
|
||
""" | ||
models__from_basic_seed = """ | ||
select * from {{ this.schema }}.seed_expected | ||
|
||
""" | ||
|
||
# | ||
# Properties | ||
# | ||
|
||
properties__schema_yml = """ | ||
version: 2 | ||
seeds: | ||
- name: seed_enabled | ||
columns: | ||
- name: birthday | ||
tests: | ||
- column_type: | ||
type: date | ||
- name: seed_id | ||
tests: | ||
- column_type: | ||
type: text | ||
|
||
- name: seed_tricky | ||
columns: | ||
- name: seed_id | ||
tests: | ||
- column_type: | ||
type: integer | ||
- name: seed_id_str | ||
tests: | ||
- column_type: | ||
type: text | ||
- name: a_bool | ||
tests: | ||
- column_type: | ||
type: boolean | ||
- name: looks_like_a_bool | ||
tests: | ||
- column_type: | ||
type: text | ||
- name: a_date | ||
tests: | ||
- column_type: | ||
type: timestamp without time zone | ||
- name: looks_like_a_date | ||
tests: | ||
- column_type: | ||
type: text | ||
- name: relative | ||
tests: | ||
- column_type: | ||
type: text | ||
- name: weekday | ||
tests: | ||
- column_type: | ||
type: text | ||
""" |
File renamed without changes.
591 changes: 586 additions & 5 deletions
591
...tional/simple_seed/data/seed_expected.sql → ...er/dbt/tests/adapter/simple_seed/seeds.py
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to preserve these as actual
.csv
files to validate this? I'm wondering if it would be easier to have a core-only test that looks at some of these edge cases (BOM, unicode etc.) and an actually "simple" seed test in the adapter zone that just validates loading csv filesThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that would be a better approach. I'll modify the code.
Update: rethinking this - the adapter zone could include a csv that checks for these cases rather than having the tests split across the two paths. No duplication.