forked from dbt-labs/dbt-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: add warning on duplicated yaml keys (dbt-labs#5146)
* add warning on duplicated yaml keys * update structure and tests * fix old test schema file * add changelog
- Loading branch information
Showing
6 changed files
with
78 additions
and
7 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,7 @@ | ||
kind: Fixes | ||
body: Add warning if yaml contains duplicate keys | ||
time: 2022-04-28T10:01:57.893956+12:00 | ||
custom: | ||
Author: jeremyyeo | ||
Issue: "5114" | ||
PR: "5146" |
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
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
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 @@ | ||
import pytest | ||
|
||
from dbt.tests.util import run_dbt_and_capture, run_dbt | ||
from dbt.exceptions import DuplicateYamlKeyException | ||
|
||
duplicate_key_schema__schema_yml = """ | ||
version: 2 | ||
models: | ||
- name: my_model | ||
models: | ||
- name: my_model | ||
""" | ||
|
||
my_model_sql = """ | ||
select 1 as fun | ||
""" | ||
|
||
|
||
class TestBasicDuplications: | ||
@pytest.fixture(scope="class") | ||
def models(self): | ||
return { | ||
"my_model.sql": my_model_sql, | ||
"schema.yml": duplicate_key_schema__schema_yml, | ||
} | ||
|
||
def test_warning_in_stdout(self, project): | ||
results, stdout = run_dbt_and_capture(["run"]) | ||
assert "Duplicate 'models' key found in yaml file models/schema.yml" in stdout | ||
|
||
def test_exception_is_raised_with_warn_error_flag(self, project): | ||
with pytest.raises(DuplicateYamlKeyException): | ||
run_dbt(["--warn-error", "run"]) |