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

Added dbt labels as part of columns info when pushing decscriptions #41

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
36 changes: 25 additions & 11 deletions dbt_superset_lineage/push_descriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ def get_datasets_from_superset(superset, superset_db_id):
break

assert datasets, "There are no datasets in Superset!"

return datasets


Expand Down Expand Up @@ -145,14 +144,16 @@ def convert_markdown_to_plain_text(md_string):

def merge_columns_info(dataset, tables):
logging.info("Merging columns info from Superset and manifest.json file.")

key = dataset['key']
sst_columns = dataset['columns']
dbt_columns = tables.get(key, {}).get('columns', {})

sst_description = dataset['description']
dbt_description = tables.get(key, {}).get('description')




sst_owners = dataset['owners']

columns_new = []
Expand All @@ -166,16 +167,29 @@ def merge_columns_info(dataset, tables):
'id': sst_column['id']
}

# add column descriptions
if column_name in dbt_columns \
and 'description' in dbt_columns[column_name] \
# add column descriptions and labels
if column_name in dbt_columns :
if 'description' in dbt_columns[column_name] \
and (sst_column['expression'] is None # database columns
or sst_column['expression'] == ''):
description = dbt_columns[column_name]['description']
description = convert_markdown_to_plain_text(description)
else:
description = sst_column['description']
column_new['description'] = description

description = dbt_columns[column_name]['description']
description = convert_markdown_to_plain_text(description)
else:
description = sst_column['description']

column_new['description'] = description

# Check if 'meta' field exists in dbt_columns
if 'meta' in dbt_columns[column_name] \
and 'label' in dbt_columns[column_name]['meta']:
label = dbt_columns[column_name]['meta']['label']
label = convert_markdown_to_plain_text(label)

else:
label = sst_column['verbose_name']

column_new['verbose_name'] = label

columns_new.append(column_new)

Expand Down