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

Add the ability to automatically use different node_color for different materializations #534

Open
kdeggelman opened this issue Nov 21, 2024 · 1 comment
Labels
enhancement New feature or request triage

Comments

@kdeggelman
Copy link

Describe the feature

When looking at the lineage graph, it would be helpful to visually distinguish models based on their materialization strategies. Ideally the choice of colors would be configurable by the user.

Describe alternatives you've considered

We can manually set the node_color for folders and individual models, so we could organize all of our tables in a folder, views in another folder, incremental in another, etc. This would be a big departure from how we're currently structuring our folders.

Additional context

N/A

Who will this benefit?

What kind of use case will this feature be useful for? Please be specific and provide examples, this will help us prioritize properly.
This will benefit all users of dbt-docs who would like to visually distinguish different materializations in their lineage graphs.
There have been a few asks about this feature in Slack. For example, here and here.

Are you interested in contributing this feature?

Yes, I'd like to add the code to support this feature. It would be great to hear if the maintainers will be willing to accept a PR with this functionality before I embark.

@kdeggelman kdeggelman added enhancement New feature or request triage labels Nov 21, 2024
@kdeggelman
Copy link
Author

My first attempt at this was adding an else block here:

var color_config = _.get(el, ['data', 'docs', 'node_color'])
if (color_config && colorValidation.isValidColor(color_config)) {
el.data['node_color'] = color_config;
}

            } else {
                var materialization = _.get(el, ['data', 'config', 'materialized'])
                var colorMap = {
                    'view': '#0094b3',
                    'table': '#4f2d7f',
                    'incremental': '#90004f',
                    'ephemeral': '#adafaf'
                }
                var color = colorMap[materialization]
                if (color) {
                    el.data['node_color'] = color
                }
            }

This worked just fine! But it is my understanding making something like this "opt-in" and adding the ability to customize the colors would require changes in dbt-core to pass the configuration into manifest.json. But at that point, it probably makes more sense to keep logic like this out of dbt-docs and instead have the logic live in dbt-core.

My current thinking is:

  • Leave dbt-docs alone
  • Add some settings/configuration to dbt-core to enable coloring by materialization, and specify the colors
  • Modify the process that sets config.docs.node_color to use the settings from above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request triage
Projects
None yet
Development

No branches or pull requests

1 participant