-
-
Notifications
You must be signed in to change notification settings - Fork 74
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
Exposures command references wrong models due to same alias #282
Comments
Make a minimal example (e.g. only 2 models), specifying your expected and actual behaviour, then I'll have a look. |
As you noticed in #286 (comment), clashing table names are not supported. Dependencies are manually parsed from Metabase cards, including native SQL queries, and there's no way to distinguish which table Here's the code, if you're interested dbt-metabase/dbtmetabase/_exposures.py Lines 221 to 311 in 602192e
|
I'm experimenting with an enhancement to allow clashing table names in #287. @jefersonmsantos Can you try installing from this branch and test it out with your project?
|
@gouline With this branch, all
|
Try reinstalling and running again, you should have a For example:
I haven't used dbt with BigQuery, not sure what it would use for |
@gouline Environment:
Example: payments.sql {{ config(alias='transactions') }}
select * from {{ ref('stg_payments') }} Generated depends.yaml models:
my_project.work.transactions: ref('payments')
my_project.work.customers: ref('customers')
my_project.work.orders: ref('orders')
my_project.work.stg_customers: ref('stg_customers')
my_project.work.stg_payments: ref('stg_payments')
my_project.work.stg_orders: ref('stg_orders')
depends:
- my_project.work.transactions Generated exposures.yml version: 2
exposures:
- name: test
label: test
description: "### Visualization: Table\n\nNo description provided in Metabase\n\
\n#### Query\n\n```\n SELECT *\n FROM work.transactions\n```\n\n#### Metadata\n\
\nMetabase ID: __xxx__\n\nCreated On: __2024-11-30T14:34:53.501679Z__"
type: analysis
url: xxxxxxx
maturity: medium
owner:
name: xxxxxxx
email: xxxxxxx
depends_on:
- ref('payments')
meta:
average_query_time: '0:03.428'
last_used_at: '2024-12-06T03:45:29.091341Z' |
Thanks for confirming! I'm nervous about deploying this globally, so I will either provide it as a feature flag or fall back to it whenever conflicting model names are detected. |
Thank you ! Since I always use |
@yuichi-github-dev Give this another go before I release (I don't have access to BigQuery for testing):
|
@gouline Previous version
version: 2
exposures:
- name: test
label: test
description: "### Visualization: Table\n\nNo description provided in Metabase\n\
\n#### Query\n\n```\n SELECT *\n FROM work.transactions\n```\n\n#### Metadata\n\
\nMetabase ID: __218__\n\nCreated On: __2024-11-30T14:34:53.501679Z__"
type: analysis
url: xxxxxxx
maturity: medium
owner:
name: xxxxxxx
email: xxxxxxx
depends_on:
- ref('payments')
meta:
average_query_time: '0:02.805'
last_used_at: '2024-12-16T00:41:28.263506Z' Current version
version: 2
exposures:
- name: test
label: test
description: "### Visualization: Table\n\nNo description provided in Metabase\n\
\n#### Query\n\n```\n SELECT *\n FROM work.transactions\n```\n\n#### Metadata\n\
\nMetabase ID: __218__\n\nCreated On: __2024-11-30T14:34:53.501679Z__"
type: analysis
url: xxxxxxx
maturity: medium
owner:
name: xxxxxxx
email: xxxxxxx
depends_on: []
meta:
average_query_time: '0:02.805'
last_used_at: '2024-12-16T00:41:28.263506Z' |
Thanks for checking, this should hopefully resolve it:
If that doesn't work, can you please go to |
@gouline Here are the details of my current setup:
Generated exposure.yml : version: 2
exposures:
- name: test
label: test
description: "### Visualization: Table\n\nNo description provided in Metabase\n\
\n#### Query\n\n```\n SELECT *\n FROM work.transactions\n```\n\n#### Metadata\n\
\nMetabase ID: __218__\n\nCreated On: __2024-11-30T14:34:53.501679Z__"
type: analysis
url: xxxxxxx
maturity: medium
owner:
name: xxxxxxx
email: xxxxxxx
depends_on:
- ref('payments')
meta:
average_query_time: '0:02.805'
last_used_at: '2024-12-16T00:41:28.263506Z' |
Great, released in 1.4.0! Tests only cover PostgreSQL and we confirmed BigQuery here, but it should theoretically work with MySQL, Snowflake, Redshift, Databricks, etc. |
We use dbt alias on our dbt project. For example, below model has name
finance__subscriptions
but its alias issubscriptions
. The table created on the warehouse will besubscriptions
and Metabase will read this table with namesubscriptions
.When we use command
dbt-metabase exposures
, charts / dashboards / queries using this model will be identified with depends on by the name of the table on Metabase, that issubscriptions
.However, models are loaded from manifest_file on
_exposures.py
by the name of the model, that isfinance__subscriptions
:This way, they will not match and this finance__subscription model will not be referenced as a dependency. Also, we have a source with name
subscriptions
, that matches the alias of the other model. So, on this situation, exposures are referencing a source instead of the correct model.Is there anyway to reference not only table_name, but also schemas to avoid these mistakes? Is there anyway to consider alias instead of names?
The text was updated successfully, but these errors were encountered: