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
fix: fix joined table with aliases in metric #9842
Conversation
✅ Deploy Preview for peaceful-bassi-cbf284 canceled.
|
When trying to compile the same join alias you have on the screenshots using the CLI: diff --git a/examples/full-jaffle-shop-demo/dbt/models/schema.yml b/examples/full-jaffle-shop-demo/dbt/models/schema.yml
index 624508de6..6118fd529 100755
--- a/examples/full-jaffle-shop-demo/dbt/models/schema.yml
+++ b/examples/full-jaffle-shop-demo/dbt/models/schema.yml
@@ -93,6 +93,7 @@ models:
meta:
joins:
- join: customers
+ alias: foo
sql_on: ${customers.customer_id} = ${orders.customer_id}
columns:
- name: order_id
@@ -102,6 +103,9 @@ models:
description: This is a unique identifier for an order
meta:
metrics:
+ first_name_count:
+ type: count_distinct
+ field: ${foo.first_name} IS NOT NULL
unique_order_count:
type: count_distinct
completed_or_shipped_order_count: I am getting this error: |
Fixed, there might be more like this like I mentioned in the description
|
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.
## [0.1075.1](0.1075.0...0.1075.1) (2024-04-23) ### Bug Fixes * fix joined table with aliases in metric ([#9842](#9842)) ([25aef88](25aef88))
🎉 This PR is included in version 0.1075.1 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Closes: #9726
Solution
Generate a mapping with all the joins tables and aliases so we can evaluate the alias in the dimension reference method
Description:
This PR is only fixing the specified issue with nested joins , alias and sql metric. There are other scenarios that are not covered on this PR , like dimensions, user attributes, etc. THe approach should be similar to this fix though.
Before
After:
Reviewer actions