[Bug] Saved query exports run out of DAG order if they depend on dimensions in other Semantic Models for filters / group-bys #10016
Labels
bug
Something isn't working
High Severity
bug with significant impact that should be resolved in a reasonable timeframe
semantic
Issues related to the semantic layer
wontfix
Not a bug or out of scope for dbt-core
Milestone
Is this a new bug in dbt-core?
Current Behavior
metrics
andsaved_queries
can depend onsemantic_models
directly (aggregating over their measures) or indirectly (grouping by / filtering on their dimensions). Today, dbt can detect and understand only the first type of dependency at parse time.Previous discussion of this limitation:
depends_on
#7854 (comment)depends_on
will include semantic_models based on measures, but not based on filters docs.getdbt.com#3682This has two negative consequences:
dbt list
andmanifest.json
, there are no links betweenmetrics
/saved_queries
and thesemantic_models
they depend on indirectly (via dimensions), so we show an incomplete picture of the DAG[dbt] model -> semantic_model -> metric -> saved_query
Expected Behavior
dbt list -s +<my_saved_query>
should include all semantic models that the saved query depends ondbt build -s +<my_saved_query>
should execute resources in appropriate order, with all requisite models upstream of the saved query (no-op / export)In an ideal world, we'd capture these dependencies at parsing time, so that they would also be reflected in the saved query's
depends_on.nodes
. IMO it's sufficient to add these edges when we're constructing + linking the DAG, similar to howdbt build
adds edges for tests (model -> test -> model
).Steps To Reproduce
jaffle-sl-template
dbt list --select +saved_query:new_customer_orders --resource-type semantic_model
— the saved querynew_customer_orders
depends only onsemantic_model:jaffle_shop.orders
, even though it needs to be grouped bycustomers.customer_name
and filtered oncustomers.customer_type
dbt build
runsnew_customer_orders
export (NO-OP indbt-core
) beforecustomers
Relevant log output
Environment
Which database adapter are you using with dbt?
No response
Additional Context
DSI PR:
SavedQueryDependencyResolver
dbt-semantic-interfaces#278Spike of
dbt-core
implementation:"It works" (though the current implementation is very naïve):
The text was updated successfully, but these errors were encountered: