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

DBT-774: Modify the macro for TestRight to return empty string('') instead of NULL #143

Closed
wants to merge 3 commits into from
Closed
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
2 changes: 1 addition & 1 deletion dbt/include/hive/macros/utils/right.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
{% macro hive__right(string_text, length_expression) %}

case when {{ length_expression }} = 0
then NULL
then ''
else
substr(
{{ string_text }},
Expand Down
74 changes: 3 additions & 71 deletions tests/functional/adapter/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,32 +237,8 @@ def models(self):
}


models__test_concat_sql = """
with util_data as (

select * from {{ ref('data_concat') }}

)

select
{{ concat(['input_1', 'input_2']) }} as actual,
output as expected

from util_data
"""


class TestConcat(BaseConcat):
@pytest.fixture(scope="class")
def seeds(self):
return {"data_concat.csv": seeds__data_concat_csv}

@pytest.fixture(scope="class")
def models(self):
return {
"test_concat.yml": models__test_concat_yml,
"test_concat.sql": self.interpolate_macro_namespace(models__test_concat_sql, "concat"),
}
pass


models__test_dateadd_sql = """
Expand Down Expand Up @@ -389,32 +365,8 @@ class TestExcept(BaseExcept):
pass


models__test_hash_sql = """
with util_data as (

select * from {{ ref('data_hash') }}

)

select
{{ hash('input_1') }} as actual,
output as expected

from util_data
"""


class TestHash(BaseHash):
@pytest.fixture(scope="class")
def seeds(self):
return {"data_hash.csv": seeds__data_hash_csv}

@pytest.fixture(scope="class")
def models(self):
return {
"test_hash.yml": models__test_hash_yml,
"test_hash.sql": self.interpolate_macro_namespace(models__test_hash_sql, "hash"),
}
pass


class TestIntersect(BaseIntersect):
Expand Down Expand Up @@ -642,28 +594,8 @@ def models(self):
}


models__test_right_sql = """
with util_data as (
select * from {{ ref('data_right') }}
)
select
{{ right('string_text', 'length_expression') }} as actual,
coalesce(output, '') as expected
from util_data
"""


class TestRight(BaseRight):
@pytest.fixture(scope="class")
def seeds(self):
return {"data_right.csv": seeds__data_right_csv}

@pytest.fixture(scope="class")
def models(self):
return {
"test_right.yml": models__test_right_yml,
"test_right.sql": self.interpolate_macro_namespace(models__test_right_sql, "right"),
}
pass


models__test_safe_cast_sql = """
Expand Down