-
Notifications
You must be signed in to change notification settings - Fork 112
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
Feature/hackathon model generator #83
Feature/hackathon model generator #83
Conversation
Not entirely sure why the CircleCi build is failing 🤔 Let me know if there is anything needed on my end! |
@fivetran-joemarkiewicz agreed, the copy-pasting is no fun and creates a barrier!
I'm not personally worried about this not being able to run shell commands in the dbt Cloud IDE. It seems to me that the macros would actually work correctly in dbt Cloud -- the user just wouldn't be able to execute the script there, right? The user would have to execute the script in some kind of bash/zsh-compatible shell, which I think is reasonable. Taking it for a spin 🚗I setup a couple sources and ran the new command using two sources that exist plus a bogus one that doesn't exist: dbt run-operation codegen.create_base_models --args '{"source_name": "dbt_dbeatty", "tables": ["raw_orders", "raw_customers", "asdfasdf"]}' The output was this: source dbt_packages/codegen/bash_scripts/base_model_creation.sh dbt_dbeatty raw_orders &&
source dbt_packages/codegen/bash_scripts/base_model_creation.sh dbt_dbeatty raw_customers &&
source dbt_packages/codegen/bash_scripts/base_model_creation.sh dbt_dbeatty asdfasdf (There was an extra set of Coping and pasting that output to run those commands created the following files:
The happy path generated this content: with source as (
select * from {{ source('dbt_dbeatty', 'raw_customers') }}
),
renamed as (
select
id,
first_name,
last_name
from source
)
select * from renamed And the content of the missing file on the not-so-happy path was reasonable too: Macro 'macro.codegen.generate_base_model' (macros/generate_base_model.sql) depends on a source named 'dbt_dbeatty.asdfasdf' which was not found or is disabled
> in macro generate_base_model (macros/generate_base_model.sql)
> called by macro generate_base_model (macros/generate_base_model.sql) Next stepsI'm not sure why the CircleCI build is failing either. Regardless, this PR is currently targeting So I'm going to try merging From there, this feature will be included in the next release (whether that is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the very first time I used codegen, this feature is everything I wanted @fivetran-joemarkiewicz! 🤩
It's like setting sail on a new adventure and hoisting the sails to catch the wind. This new feature will surely help us all navigate through the sea of data and reach new, unexplored shores. Keep up the good work, matey! 🚢
Hey @dbeatty10 thanks for picking this PR up and I am glad you were able to make some edits and set this PR to sea within the main branch! I'm happy it was able to be merged and hope it helps others out there! |
* feature/hackathon-model-generator * documentation updates * final bash script changes * readme updates * changelog entry * Remove `columns_array` and `&&` and add some light commentary Co-authored-by: Doug Beatty <doug.beatty@dbtlabs.com> Co-authored-by: Doug Beatty <44704949+dbeatty10@users.noreply.github.com>
Hackathon PR
This is a:
main
dev/
branchdev/
branchDescription & motivation
Currently, the dbt-codegen package has macros that output the source, base, and other model information in the terminal. While this is great, I think it can be expanded upon even further to make this process more seamless and have have greater versatility. A big blocker from me using this package is that there is a lot of copy/pasting that takes place.
Therefore, I added some new functionality that builds off the
generate_base_model
macro and allows for the package to create the model files in your local dbt project. This is achieved by leveraging a new bash script that can be run from the package and will output a series of terminal commands. These terminal commands can then be copy/pasted and ran to generate the model files with the output of thegenerate_base_model
included within them.Checklist
Additional Notes
I also was unsure what types of tests (if any) should be used for the macro and bash script. Therefore, I have omitted them for the time being.