Forum Discussion

Janzze96's avatar
Janzze96
Regular Visitor
22 days ago
Solved

direct lake semantic model and DBT materialization - breaks model

Hi,

 

Not sure if others have run into this issue when using DBT with Fabric sql warehouses.

 

Issue: Utilizing DBT to run models that feed data into direct lake semantic model this causes issues during refresh.
Since the underlaying tables are deleted and created by DBT direct lake looses the table (parquet files) for sometime. 

Semantic model  has the setting on to keep direct lake up to date. Does help reduce the issue.
Only real fix I have found for this is either to use only incremental models so the table stays in place.

Change materialization for gold tables to something like https://github.com/ryan-schofield/fabric_table_materialization



The error the reports show that are running on top of the model is a general issue:
We cannot process this request right now because the OneLake security configuration has changed. Please refresh the semantic model to resolve this issue.


Have other users found better solutions to this problem?

  • Hi Janzze96 

     

    Yes, you are correct in that the direct like semantic model is bound to the tables and files when it is created. So if those files, all tables are deleted the semantic model will no longer work successfully. And this is how it works as by design. So I would highly recommend incremental learning or truncate and reload of the tables but not to delete the tables. That should overcome your issue.

  • Hi Janzze96,

     

    I have seen the same general pattern when a dbt run performs a destructive rebuild of a table that is already being consumed by a Direct Lake semantic model.

     

    Direct Lake refresh is essentially a metadata reframing operation against the Delta tables in OneLake. It can pick up new data and table metadata changes, but it cannot provide continuity during a period where the underlying table has been dropped and recreated. That also explains why increasing the semantic model refresh frequency does not really solve this - the table temporarily stops existing as the same stable source object.

     

    For tables exposed to Direct Lake, I would treat the table itself as a persistent serving contract and avoid ordinary drop-and-recreate materialization during routine production runs.

     

    The approach I would use is:

    • Keep the final Gold table in place.
    • Load changes through an incremental strategy such as MERGE, using a reliable unique_key.
    • Use on_schema_change deliberately so that schema changes are handled rather than silently forcing destructive rebuilds.
    • Run the semantic model refresh only after the dbt job has completed successfully.
    • Reserve --full-refresh for controlled maintenance windows because it can recreate the relation and temporarily invalidate downstream consumers.

    If you occasionally need to rebuild all rows, another option is a custom materialization that preserves the target table and replaces its contents through TRUNCATE/DELETE followed by INSERT, where that pattern is supported and appropriate. The important part is to avoid dropping the published table itself.

     

    I would also separate the build layer from the serving layer where possible:

    • dbt builds or validates data in staging objects.
    • The final Gold table is updated in place.
    • Data-quality checks complete.
    • The Direct Lake semantic model is reframed.
    • Reports are then allowed to consume the new version.

    A staging-table rename or swap needs testing as well, because although the final name may remain the same, replacing the underlying relation can still change the object that the semantic model is bound to.

     

    So I agree that incremental materialization is the right direction. I would regard it as part of the architecture for any dbt-managed table serving Direct Lake, rather than only as a temporary fix for the refresh error.

4 Replies

  • v-csrikanth's avatar
    v-csrikanth
    Community Support

    Hi Janzze96 
    We would like to inquire whether have you got the chance to check the solutions provided by ShivekMaharaj GilbertQi in community to resolve the issue. We hope the information provided helps to clear the query. Should you have any further queries, kindly feel free to contact the Microsoft Fabric community.

  • Hi Janzze96 

     

    Yes, you are correct in that the direct like semantic model is bound to the tables and files when it is created. So if those files, all tables are deleted the semantic model will no longer work successfully. And this is how it works as by design. So I would highly recommend incremental learning or truncate and reload of the tables but not to delete the tables. That should overcome your issue.

  • ShivekMaharaj's avatar
    ShivekMaharaj
    Impactful Individual

    Hi Janzze96,

     

    I have seen the same general pattern when a dbt run performs a destructive rebuild of a table that is already being consumed by a Direct Lake semantic model.

     

    Direct Lake refresh is essentially a metadata reframing operation against the Delta tables in OneLake. It can pick up new data and table metadata changes, but it cannot provide continuity during a period where the underlying table has been dropped and recreated. That also explains why increasing the semantic model refresh frequency does not really solve this - the table temporarily stops existing as the same stable source object.

     

    For tables exposed to Direct Lake, I would treat the table itself as a persistent serving contract and avoid ordinary drop-and-recreate materialization during routine production runs.

     

    The approach I would use is:

    • Keep the final Gold table in place.
    • Load changes through an incremental strategy such as MERGE, using a reliable unique_key.
    • Use on_schema_change deliberately so that schema changes are handled rather than silently forcing destructive rebuilds.
    • Run the semantic model refresh only after the dbt job has completed successfully.
    • Reserve --full-refresh for controlled maintenance windows because it can recreate the relation and temporarily invalidate downstream consumers.

    If you occasionally need to rebuild all rows, another option is a custom materialization that preserves the target table and replaces its contents through TRUNCATE/DELETE followed by INSERT, where that pattern is supported and appropriate. The important part is to avoid dropping the published table itself.

     

    I would also separate the build layer from the serving layer where possible:

    • dbt builds or validates data in staging objects.
    • The final Gold table is updated in place.
    • Data-quality checks complete.
    • The Direct Lake semantic model is reframed.
    • Reports are then allowed to consume the new version.

    A staging-table rename or swap needs testing as well, because although the final name may remain the same, replacing the underlying relation can still change the object that the semantic model is bound to.

     

    So I agree that incremental materialization is the right direction. I would regard it as part of the architecture for any dbt-managed table serving Direct Lake, rather than only as a temporary fix for the refresh error.

  • v-csrikanth's avatar
    v-csrikanth
    Community Support

    Hi Janzze96 

    We haven’t heard from you on the last response and was just checking back to see if you have a resolution yet. And, if you have any further query do let us know.


    Thank you.