-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
52 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,6 @@ | ||
kind: Fixes | ||
body: _get_doc_blocks is crashing parsing if .format is called | ||
time: 2025-02-18T13:47:45.659731Z | ||
custom: | ||
Author: aranke | ||
Issue: "11310" |
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,45 @@ | ||
import json | ||
import os | ||
|
||
import pytest | ||
|
||
from dbt.tests.util import run_dbt | ||
|
||
docs_md = """{% docs test_doc %} | ||
This is a test for column {test_name} | ||
{% enddocs %} | ||
""" | ||
|
||
schema_yml = """ | ||
models: | ||
- name: my_colors | ||
columns: | ||
- name: id | ||
description: "{{ doc('test_doc').format(test_name = 'id') }}" | ||
- name: color | ||
description: "{{ 'This is a test for column {test_name}'.format(test_name = 'color') }}" | ||
""" | ||
|
||
|
||
class TestDocBlocksBackCompat: | ||
@pytest.fixture(scope="class") | ||
def models(self): | ||
return { | ||
"my_colors.sql": "select 1 as id, 'blue' as color", | ||
"schema.yml": schema_yml, | ||
"docs.md": docs_md, | ||
} | ||
|
||
def test_doc_blocks_back_compat(self, project): | ||
run_dbt(["parse"]) | ||
|
||
assert os.path.exists("./target/manifest.json") | ||
|
||
with open("./target/manifest.json") as fp: | ||
manifest = json.load(fp) | ||
|
||
model_data = manifest["nodes"]["model.test.my_colors"] | ||
|
||
for column_name, column in model_data["columns"].items(): | ||
assert column["description"] == f"This is a test for column {column_name}" | ||
assert column["doc_blocks"] == [] |