Forum Discussion

CoulterJames2's avatar
CoulterJames2
Icon for Advocate II rankAdvocate II
9 months ago
Solved

Materialized Lake View Refresh fails if Workspace is renamed

Hi, I have come across an issue with MLV in Fabric.   1. Create a workspace called DEMO 2. Create two lakehouses, one representing bronze layer and one representing silver layer 3. Create a table...
  • apturlov's avatar
    9 months ago

    Hi CoulterJames2. Could you please provide details about how you created and refresh your MLV (Materialized Lake View)?

     

    The likely reason why you are seeing this error is because when you create your MLV using Spark SQL in a Notebook you use a three-part name for the source table(s) [workspace.lakehouse.schema].MLV_NAME. Because MLV is essentially a delta table on OneLake, its data is stored in the OneLake file system and its metadata is stored in the OneLake catalog. When you renamed the workspace the file path to the MLV data changed but the metadata was not updated. You need to update your MLV metadata by updating your Spark SQL script with the correct fully qualified name for the origin table. You need to use Spark SQL script for that:

    CREATE [OR REPLACE] MATERIALIZED LAKE VIEW [IF NOT EXISTS][workspace.lakehouse.schema].MLV_Identifier 
    [( 
        CONSTRAINT constraint_name1 CHECK (condition expression1)[ON MISMATCH DROP | FAIL],  
        CONSTRAINT constraint_name2 CHECK (condition expression2)[ON MISMATCH DROP | FAIL] 
    )] 
    [PARTITIONED BY (col1, col2, ... )] 
    [COMMENT "description or comment"] 
    [TBLPROPERTIES ("key1"="val1", "key2"="val2", ... )] 
    AS select_statement

    You can read more here Spark SQL Reference for Materialized Lake Views - Microsoft Fabric | Microsoft Learn

     

    If you find this answer useful or solving your problem please consider giving kudos and/or marking as a solution.