-
Notifications
You must be signed in to change notification settings - Fork 295
Add support render for versioned dbt models. #516
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
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
4203270
Fix dbt versioning.
binhnq94 4108bac
Fix logics when node_dict["resource_type"] != DbtResourceType.MODEL
binhnq94 4c94830
Use name instead of alias if node don't have alias property.
binhnq94 9cd9a26
Add dev dbt project for model version.
binhnq94 3d1c20e
Add test and rename dbt_project to model_version
binhnq94 9fd46a1
update
binhnq94 d111aa7
Add manifest file.
binhnq94 014c127
🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
pre-commit-ci[bot] c90a7f4
Add noted document!
binhnq94 4747ad2
Add noted document!
binhnq94 1814712
Add mark integration
binhnq94 06cfdda
Remove license and add test for dependencies.
binhnq94 90f8b39
update dbt version of integration setup
binhnq94 bf2a328
Fix improper relation name (too many dotted names)
binhnq94 deb9964
Change macro drop_table to be different as default macro.
binhnq94 898569e
Exclude manifest file.
binhnq94 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| ## `jaffle_shop` | ||
|
|
||
| `jaffle_shop` is a fictional ecommerce store. This dbt project transforms raw data from an app database into a customers and orders model ready for analytics. | ||
|
|
||
| See [dbt's documentation](https://github.com/dbt-labs/jaffle_shop) for more info. | ||
|
|
||
| ### Modifications | ||
|
|
||
| This project has been modified from the original to highlight some of the features of Cosmos. Namely: | ||
|
|
||
| - tags have been added to the models | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| name: 'jaffle_shop' | ||
|
|
||
| config-version: 2 | ||
| version: '0.1' | ||
|
|
||
| profile: 'jaffle_shop' | ||
|
|
||
| model-paths: ["models"] | ||
| seed-paths: ["seeds"] | ||
| test-paths: ["tests"] | ||
| analysis-paths: ["analysis"] | ||
| macro-paths: ["macros"] | ||
|
|
||
| target-path: "target" | ||
| clean-targets: | ||
| - "target" | ||
| - "dbt_modules" | ||
| - "logs" | ||
|
|
||
| require-dbt-version: [">=1.0.0", "<2.0.0"] | ||
|
|
||
| models: | ||
| jaffle_shop: | ||
| materialized: table | ||
| staging: | ||
| materialized: view |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| with customers as ( | ||
|
|
||
| select * from {{ ref('stg_customers') }} | ||
|
|
||
| ), | ||
|
|
||
| orders as ( | ||
|
|
||
| select * from {{ ref('stg_orders') }} | ||
|
|
||
| ), | ||
|
|
||
| payments as ( | ||
|
|
||
| select * from {{ ref('stg_payments') }} | ||
|
|
||
| ), | ||
|
|
||
| customer_orders as ( | ||
|
|
||
| select | ||
| customer_id, | ||
|
|
||
| min(order_date) as first_order, | ||
| max(order_date) as most_recent_order, | ||
| count(order_id) as number_of_orders | ||
| from orders | ||
|
|
||
| group by customer_id | ||
|
|
||
| ), | ||
|
|
||
| customer_payments as ( | ||
|
|
||
| select | ||
| orders.customer_id, | ||
| sum(amount) as total_amount | ||
|
|
||
| from payments | ||
|
|
||
| left join orders on | ||
| payments.order_id = orders.order_id | ||
|
|
||
| group by orders.customer_id | ||
|
|
||
| ), | ||
|
|
||
| final as ( | ||
|
|
||
| select | ||
| customers.customer_id, | ||
| customers.first_name, | ||
| customers.last_name, | ||
| customers.full_name, | ||
| customer_orders.first_order, | ||
| customer_orders.most_recent_order, | ||
| customer_orders.number_of_orders, | ||
| customer_payments.total_amount as customer_lifetime_value | ||
|
|
||
| from customers | ||
|
|
||
| left join customer_orders | ||
| on customers.customer_id = customer_orders.customer_id | ||
|
|
||
| left join customer_payments | ||
| on customers.customer_id = customer_payments.customer_id | ||
|
|
||
| ) | ||
|
|
||
| select * from final |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| with customers as ( | ||
|
|
||
| select * from {{ ref('stg_customers', v=1) }} | ||
|
|
||
| ), | ||
|
|
||
| orders as ( | ||
|
|
||
| select * from {{ ref('stg_orders') }} | ||
|
|
||
| ), | ||
|
|
||
| payments as ( | ||
|
|
||
| select * from {{ ref('stg_payments') }} | ||
|
|
||
| ), | ||
|
|
||
| customer_orders as ( | ||
|
|
||
| select | ||
| customer_id, | ||
|
|
||
| min(order_date) as first_order, | ||
| max(order_date) as most_recent_order, | ||
| count(order_id) as number_of_orders | ||
| from orders | ||
|
|
||
| group by customer_id | ||
|
|
||
| ), | ||
|
|
||
| customer_payments as ( | ||
|
|
||
| select | ||
| orders.customer_id, | ||
| sum(amount) as total_amount | ||
|
|
||
| from payments | ||
|
|
||
| left join orders on | ||
| payments.order_id = orders.order_id | ||
|
|
||
| group by orders.customer_id | ||
|
|
||
| ), | ||
|
|
||
| final as ( | ||
|
|
||
| select | ||
| customers.customer_id, | ||
| customers.first_name, | ||
| customers.last_name, | ||
| customer_orders.first_order, | ||
| customer_orders.most_recent_order, | ||
| customer_orders.number_of_orders, | ||
| customer_payments.total_amount as customer_lifetime_value | ||
|
|
||
| from customers | ||
|
|
||
| left join customer_orders | ||
| on customers.customer_id = customer_orders.customer_id | ||
|
|
||
| left join customer_payments | ||
| on customers.customer_id = customer_payments.customer_id | ||
|
|
||
| ) | ||
|
|
||
| select * from final |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| {% docs orders_status %} | ||
|
|
||
| Orders can be one of the following statuses: | ||
|
|
||
| | status | description | | ||
| |----------------|------------------------------------------------------------------------------------------------------------------------| | ||
| | placed | The order has been placed but has not yet left the warehouse | | ||
| | shipped | The order has ben shipped to the customer and is currently in transit | | ||
| | completed | The order has been received by the customer | | ||
| | return_pending | The customer has indicated that they would like to return the order, but it has not yet been received at the warehouse | | ||
| | returned | The order has been returned by the customer and received at the warehouse | | ||
|
|
||
|
|
||
| {% enddocs %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| {% set payment_methods = ['credit_card', 'coupon', 'bank_transfer', 'gift_card'] %} | ||
|
|
||
| with orders as ( | ||
|
|
||
| select * from {{ ref('stg_orders') }} | ||
|
|
||
| ), | ||
|
|
||
| payments as ( | ||
|
|
||
| select * from {{ ref('stg_payments') }} | ||
|
|
||
| ), | ||
|
|
||
| order_payments as ( | ||
|
|
||
| select | ||
| order_id, | ||
|
|
||
| {% for payment_method in payment_methods -%} | ||
| sum(case when payment_method = '{{ payment_method }}' then amount else 0 end) as {{ payment_method }}_amount, | ||
| {% endfor -%} | ||
|
|
||
| sum(amount) as total_amount | ||
|
|
||
| from payments | ||
|
|
||
| group by order_id | ||
|
|
||
| ), | ||
|
|
||
| final as ( | ||
|
|
||
| select | ||
| orders.order_id, | ||
| orders.customer_id, | ||
| orders.order_date, | ||
| orders.status, | ||
|
|
||
| {% for payment_method in payment_methods -%} | ||
|
|
||
| order_payments.{{ payment_method }}_amount, | ||
|
|
||
| {% endfor -%} | ||
|
|
||
| order_payments.total_amount as amount | ||
|
|
||
| from orders | ||
|
|
||
|
|
||
| left join order_payments | ||
| on orders.order_id = order_payments.order_id | ||
|
|
||
| ) | ||
|
|
||
| select * from final |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.