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

Render source_description fields in sources (#1484) #1494

Merged
merged 1 commit into from
May 30, 2019
Merged
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
20 changes: 19 additions & 1 deletion core/dbt/parser/util.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

import dbt.exceptions
import dbt.utils
from dbt.node_types import NodeType


def docs(node, manifest, config, column_name=None):
Expand Down Expand Up @@ -146,10 +147,27 @@ def process_docs_for_node(cls, manifest, current_project, node):
else:
column['description'] = description

@classmethod
def process_docs_for_source(cls, manifest, current_project, source):
context = {
'doc': docs(source, manifest, current_project),
}
table_description = source.get('description', '')
source_description = source.get('source_description', '')
table_description = dbt.clients.jinja.get_rendered(table_description,
context)
source_description = dbt.clients.jinja.get_rendered(source_description,
context)
source.set('description', table_description)
source.set('source_description', source_description)

@classmethod
def process_docs(cls, manifest, current_project):
for node in manifest.nodes.values():
cls.process_docs_for_node(manifest, current_project, node)
if node.resource_type == NodeType.Source:
cls.process_docs_for_source(manifest, current_project, node)
else:
cls.process_docs_for_node(manifest, current_project, node)
return manifest

@classmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1266,7 +1266,7 @@ def expected_postgres_references_manifest(self, model_database=None):
'resource_type': 'source',
'root_path': os.getcwd(),
'schema': my_schema_name,
'source_description': "{{ doc('source_info') }}",
'source_description': 'My source',
'source_name': 'my_source',
'unique_id': 'source.test.my_source.my_table'
}
Expand Down