Skip to content
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

Add tests for cross-database cast macro #173

Merged
merged 5 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/unreleased/Features-20240412-192040.yaml
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"
33 changes: 33 additions & 0 deletions dbt-tests-adapter/dbt/tests/adapter/utils/fixture_cast.py
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
"""
23 changes: 23 additions & 0 deletions dbt-tests-adapter/dbt/tests/adapter/utils/test_cast.py
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):
dbeatty10 marked this conversation as resolved.
Show resolved Hide resolved
pass
Loading