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

folder_path and model_prefix functionality for generate_model_yaml #106

Closed
erkanncelen opened this issue Dec 21, 2022 · 3 comments · Fixed by #115
Closed

folder_path and model_prefix functionality for generate_model_yaml #106

erkanncelen opened this issue Dec 21, 2022 · 3 comments · Fixed by #115
Labels
enhancement New feature or request

Comments

@erkanncelen
Copy link
Contributor

erkanncelen commented Dec 21, 2022

Describe the feature

I want to introduce folder_path and model_prefix functionality for generate_model_yaml macro.

This way the macro can be used as:

  • {{ generate_model_yaml(model_prefix='fct_') }} --> all models starting with fct_
  • {{ generate_model_yaml(folder_path='marts/marketing') }} --> all models in marts/marketing folder
  • {{ generate_model_yaml(folder_path='marts/marketing', model_prefix='fct_') }} --> all models in marts/marketing folder starting with fct_

**Please let me know if you think this'd be a nice addition to the codegen so that I can finalise and submit my PR! **

Describe alternatives you've considered

The alternative to this approach would be providing manually made lists to the macro, which is already possible. It is however time consuming and repetitive. I believe this approach will make dbt folks' lives easier.

Additional context

This feature is not database specific, at least not in my initial design. I basically utilise manifest.json information, to retrieve all models in a project, with model names and folder paths.

Who will this benefit?

These features will be extremely beneficial when we start documenting our dbt projects. Combining the two, we will be able to generate YAMLs for any group of models we desire. I personally used my approach at two of my clients already.

Are you interested in contributing this feature?

Yes I am!
I actually have the PR almost ready, just missing the tests, waiting for the first approval.

@erkanncelen erkanncelen added the enhancement New feature or request label Dec 21, 2022
@erkanncelen
Copy link
Contributor Author

Hi @joellabes , do you think this'd be a nice addition to the codegen? If so, I want to polish it up and finish the PR

@joellabes
Copy link
Contributor

Oooooh this is a really good idea! Sorry for the delay in getting back to you.

Instead of overloading the generate_model_yaml macro, what about a new macro called something like get_models_by_prefix_in_directory(prefix, directory) which returns an array of model names that can be passed directly into the existing unchanged macro?

@erkanncelen
Copy link
Contributor Author

Hi @joellabes , thanks for your input. Your suggestion really makes sense.

I created a macro named get_models in macros/helpers directory. It takes directory and prefix arguments. Based on these arguments, it returns an array of matching model_names retrieved from the graph object.

Here I completed the PR with all requirements checked: #115
I created an integration test for "model_" prefix, which returns an array of 4 models. The test passes in all 4 environments.

Please let me know if this is good to go!

@joellabes joellabes linked a pull request Feb 1, 2023 that will close this issue
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants