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

Suggestion to materialize base models as view or table #79

Merged

Conversation

davesgonechina
Copy link
Contributor

@davesgonechina davesgonechina commented Sep 16, 2022

This is a:

  • bug fix PR with no breaking changes — please ensure the base branch is main
  • new functionality — please ensure the base branch is the latest dev/ branch
  • a breaking change — please ensure the base branch is the latest dev/ branch

Description & motivation

Add materialization parameter to generate_base_model to allow users to choose whether to materialize the model as a table or a view.

Since base models ought not to do much transformation and provide a lightweight layer atop source tables, it is not uncommon to materialize them as views while having the default materialization for a project be tables, since heavier transformation models ought not be computed on the fly as they would be on a view.

This change would also make it possible to generate base models materialized as views in bulk using the dbt-generator package.

Checklist

  • I have verified that these changes work locally
  • I have updated the README.md (if applicable)
  • I have added tests & descriptions to my models (and macros if applicable)
  • I have added an entry to CHANGELOG.md

@davesgonechina davesgonechina changed the title Feature/materialize base models as view Suggestion to materialize base models as view Sep 20, 2022
@davesgonechina davesgonechina changed the title Suggestion to materialize base models as view Suggestion to materialize base models as view or table Sep 20, 2022
davesgonechina added a commit to davesgonechina/dbt-generator that referenced this pull request Sep 21, 2022
Copy link
Contributor

@joellabes joellabes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excited to add this option! There's a few pieces of feedback to avoid backwards compatibility issues and make the naming clearer 🙏

README.md Outdated Show resolved Hide resolved
macros/generate_base_model.sql Outdated Show resolved Hide resolved
Copy link
Contributor

@joellabes joellabes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there! It shouldn't provide a materialization in all cases - most files don't actually contain materialization configs and are instead just defined in the project.yml file

macros/generate_base_model.sql Outdated Show resolved Hide resolved
davesgonechina and others added 4 commits November 23, 2022 15:49
…ve.sql

Co-authored-by: Joel Labes <joel.labes@dbtlabs.com>
Co-authored-by: Joel Labes <joel.labes@dbtlabs.com>
Co-authored-by: Joel Labes <joel.labes@dbtlabs.com>
Copy link
Contributor

@joellabes joellabes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🌠 🎉

@joellabes joellabes merged commit 8e42e2c into dbt-labs:main Nov 23, 2022
jeremyholtzman pushed a commit that referenced this pull request Apr 10, 2023
…odels-as-view

Suggestion to materialize base models as view or table
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants