-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for cross-database
cast
macro (#173)
Co-authored-by: Mike Alfare <[email protected]>
- Loading branch information
1 parent
a9f1e14
commit 9cfb21e
Showing
3 changed files
with
62 additions
and
0 deletions.
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: Features | ||
body: Cross-database `cast` macro | ||
time: 2024-04-12T19:20:40.904842-06:00 | ||
custom: | ||
Author: MichelleArk dbeatty10 | ||
Issue: "84" |
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,33 @@ | ||
# cast | ||
|
||
seeds__data_cast_csv = """field,output | ||
abc,abc | ||
123,123 | ||
, | ||
""" | ||
|
||
|
||
models__test_cast_sql = """ | ||
with data as ( | ||
select * from {{ ref('data_cast') }} | ||
) | ||
select | ||
{{ cast('field', api.Column.translate_type('string')) }} as actual, | ||
output as expected | ||
from data | ||
""" | ||
|
||
|
||
models__test_cast_yml = """ | ||
version: 2 | ||
models: | ||
- name: test_cast | ||
data_tests: | ||
- assert_equal: | ||
actual: actual | ||
expected: expected | ||
""" |
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,23 @@ | ||
import pytest | ||
|
||
from dbt.tests.adapter.utils import base_utils, fixture_cast | ||
|
||
|
||
class BaseCast(base_utils.BaseUtils): | ||
@pytest.fixture(scope="class") | ||
def seeds(self): | ||
return {"data_cast.csv": fixture_cast.seeds__data_cast_csv} | ||
|
||
@pytest.fixture(scope="class") | ||
def models(self): | ||
return { | ||
"test_cast.yml": fixture_cast.models__test_cast_yml, | ||
"test_cast.sql": self.interpolate_macro_namespace( | ||
self.interpolate_macro_namespace(fixture_cast.models__test_cast_sql, "cast"), | ||
"type_string", | ||
), | ||
} | ||
|
||
|
||
class TestCast(BaseCast): | ||
pass |