-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #114 from Teradata/MT255026_IDE-24142_1.6.x
IDE-24142: --no-inject-ephemeral-ctes flag for compile command
- Loading branch information
Showing
2 changed files
with
90 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,43 @@ | ||
fct_eph_first_sql = """ | ||
-- fct_eph_first.sql | ||
{{ config(materialized='ephemeral') }} | ||
with int_eph_first as( | ||
select * from {{ ref('int_eph_first') }} | ||
) | ||
select * from int_eph_first | ||
""" | ||
|
||
int_eph_first_sql = """ | ||
-- int_eph_first.sql | ||
{{ config(materialized='ephemeral') }} | ||
select | ||
1 as first_column, | ||
2 as second_column | ||
""" | ||
|
||
schema_yml = """ | ||
version: 2 | ||
models: | ||
- name: int_eph_first | ||
columns: | ||
- name: first_column | ||
tests: | ||
- not_null | ||
- name: second_column | ||
tests: | ||
- not_null | ||
- name: fct_eph_first | ||
columns: | ||
- name: first_column | ||
tests: | ||
- not_null | ||
- name: second_column | ||
tests: | ||
- not_null | ||
""" |
47 changes: 47 additions & 0 deletions
47
tests/functional/adapter/ephemeral/test_ephemeral_compilation.py
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,47 @@ | ||
from dbt.contracts.graph.nodes import ModelNode | ||
from dbt.contracts.results import RunExecutionResult, RunResult | ||
import pytest | ||
from dbt.tests.util import run_dbt | ||
|
||
from tests.functional.adapter.ephemeral.fixtures import ( | ||
fct_eph_first_sql, | ||
int_eph_first_sql, | ||
schema_yml | ||
) | ||
|
||
|
||
|
||
SUPPRESSED_CTE_EXPECTED_OUTPUT = """-- fct_eph_first.sql | ||
with int_eph_first as( | ||
select * from __dbt__cte__int_eph_first | ||
) | ||
select * from int_eph_first""" | ||
|
||
|
||
class TestEphemeralCompilation: | ||
@pytest.fixture(scope="class") | ||
def models(self): | ||
return { | ||
"int_eph_first.sql": int_eph_first_sql, | ||
"fct_eph_first.sql": fct_eph_first_sql, | ||
"schema.yml": schema_yml, | ||
} | ||
''' | ||
def test_ephemeral_compilation(self, project): | ||
# Note: There are no models that run successfully. This testcase tests running tests. | ||
results = run_dbt(["run"]) | ||
assert len(results) == 0 | ||
''' | ||
def test__suppress_injected_ctes(self, project): | ||
compile_output = run_dbt( | ||
["compile", "--no-inject-ephemeral-ctes" , "--select", "fct_eph_first"] | ||
) | ||
assert isinstance(compile_output, RunExecutionResult) | ||
node_result = compile_output.results[0] | ||
assert isinstance(node_result, RunResult) | ||
node = node_result.node | ||
assert isinstance(node, ModelNode) | ||
assert node.compiled_code == SUPPRESSED_CTE_EXPECTED_OUTPUT |