-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port tests for lift + shift for cross-db macros from dbt-spark (#118)
### Description Ports tests for lift + shift for cross-db macros from [dbt-labs/dbt-spark#359](dbt-labs/dbt-spark#359).
- Loading branch information
Showing
3 changed files
with
181 additions
and
2 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
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,61 @@ | ||
# SparkSQL does not support 'order by' for its 'listagg' equivalent | ||
# the argument is ignored, so let's ignore those fields when checking equivalency | ||
|
||
models__test_listagg_no_order_by_sql = """ | ||
with data as ( | ||
select * from {{ ref('data_listagg') }} | ||
), | ||
data_output as ( | ||
select * from {{ ref('data_listagg_output') }} | ||
), | ||
calculate as ( | ||
/* | ||
select | ||
group_col, | ||
{{ listagg('string_text', "'_|_'", "order by order_col") }} as actual, | ||
'bottom_ordered' as version | ||
from data | ||
group by group_col | ||
union all | ||
select | ||
group_col, | ||
{{ listagg('string_text', "'_|_'", "order by order_col", 2) }} as actual, | ||
'bottom_ordered_limited' as version | ||
from data | ||
group by group_col | ||
union all | ||
*/ | ||
select | ||
group_col, | ||
{{ listagg('string_text', "', '") }} as actual, | ||
'comma_whitespace_unordered' as version | ||
from data | ||
where group_col = 3 | ||
group by group_col | ||
union all | ||
select | ||
group_col, | ||
{{ listagg('DISTINCT string_text', "','") }} as actual, | ||
'distinct_comma' as version | ||
from data | ||
where group_col = 3 | ||
group by group_col | ||
union all | ||
select | ||
group_col, | ||
{{ listagg('string_text') }} as actual, | ||
'no_params' as version | ||
from data | ||
where group_col = 3 | ||
group by group_col | ||
) | ||
select | ||
calculate.actual, | ||
data_output.expected | ||
from calculate | ||
left join data_output | ||
on calculate.group_col = data_output.group_col | ||
and calculate.version = data_output.version | ||
""" |
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,117 @@ | ||
import pytest | ||
|
||
from dbt.tests.adapter.utils.test_any_value import BaseAnyValue | ||
from dbt.tests.adapter.utils.test_bool_or import BaseBoolOr | ||
from dbt.tests.adapter.utils.test_cast_bool_to_text import BaseCastBoolToText | ||
from dbt.tests.adapter.utils.test_concat import BaseConcat | ||
from dbt.tests.adapter.utils.test_dateadd import BaseDateAdd | ||
from dbt.tests.adapter.utils.test_datediff import BaseDateDiff | ||
from dbt.tests.adapter.utils.test_date_trunc import BaseDateTrunc | ||
from dbt.tests.adapter.utils.test_escape_single_quotes import BaseEscapeSingleQuotesQuote | ||
from dbt.tests.adapter.utils.test_except import BaseExcept | ||
from dbt.tests.adapter.utils.test_hash import BaseHash | ||
from dbt.tests.adapter.utils.test_intersect import BaseIntersect | ||
from dbt.tests.adapter.utils.test_last_day import BaseLastDay | ||
from dbt.tests.adapter.utils.test_length import BaseLength | ||
from dbt.tests.adapter.utils.test_position import BasePosition | ||
from dbt.tests.adapter.utils.test_replace import BaseReplace | ||
from dbt.tests.adapter.utils.test_right import BaseRight | ||
from dbt.tests.adapter.utils.test_safe_cast import BaseSafeCast | ||
from dbt.tests.adapter.utils.test_split_part import BaseSplitPart | ||
from dbt.tests.adapter.utils.test_string_literal import BaseStringLiteral | ||
|
||
# requires modification | ||
from dbt.tests.adapter.utils.test_listagg import BaseListagg | ||
from dbt.tests.adapter.utils.fixture_listagg import models__test_listagg_yml | ||
from tests.functional.adapter.utils.fixture_listagg import models__test_listagg_no_order_by_sql | ||
|
||
|
||
class TestAnyValue(BaseAnyValue): | ||
pass | ||
|
||
|
||
class TestBoolOr(BaseBoolOr): | ||
pass | ||
|
||
|
||
class TestCastBoolToText(BaseCastBoolToText): | ||
pass | ||
|
||
|
||
class TestConcat(BaseConcat): | ||
pass | ||
|
||
|
||
class TestDateAdd(BaseDateAdd): | ||
pass | ||
|
||
|
||
# This test generates a super long create table sentence that exceeds HiveMetastore's limit | ||
@pytest.mark.skip_profile("databricks_cluster", "databricks_sql_endpoint") | ||
class TestDateDiff(BaseDateDiff): | ||
pass | ||
|
||
|
||
class TestDateTrunc(BaseDateTrunc): | ||
pass | ||
|
||
|
||
class TestEscapeSingleQuotes(BaseEscapeSingleQuotesQuote): | ||
pass | ||
|
||
|
||
class TestExcept(BaseExcept): | ||
pass | ||
|
||
|
||
class TestHash(BaseHash): | ||
pass | ||
|
||
|
||
class TestIntersect(BaseIntersect): | ||
pass | ||
|
||
|
||
class TestLastDay(BaseLastDay): | ||
pass | ||
|
||
|
||
class TestLength(BaseLength): | ||
pass | ||
|
||
|
||
# SparkSQL does not support 'order by' for its 'listagg' equivalent | ||
# the argument is ignored, so let's ignore those fields when checking equivalency | ||
class TestListagg(BaseListagg): | ||
@pytest.fixture(scope="class") | ||
def models(self): | ||
return { | ||
"test_listagg.yml": models__test_listagg_yml, | ||
"test_listagg.sql": self.interpolate_macro_namespace( | ||
models__test_listagg_no_order_by_sql, "listagg" | ||
), | ||
} | ||
|
||
|
||
class TestPosition(BasePosition): | ||
pass | ||
|
||
|
||
class TestReplace(BaseReplace): | ||
pass | ||
|
||
|
||
class TestRight(BaseRight): | ||
pass | ||
|
||
|
||
class TestSafeCast(BaseSafeCast): | ||
pass | ||
|
||
|
||
class TestSplitPart(BaseSplitPart): | ||
pass | ||
|
||
|
||
class TestStringLiteral(BaseStringLiteral): | ||
pass |