Forum Discussion

AdamFry's avatar
AdamFry
Icon for Advocate I rankAdvocate I
2 years ago
Solved

Writing to a Lakehouse in different workspace from Notebook

Hi there, I've been struggling to find good documentation on how to read data from a lakehouse in one workspace and after applying some transformations, write it to a different lakehouse in a differe...
  • frithjof_v's avatar
    2 years ago

    You can use the fully qualified path to write to a Lakehouse in another workspace. 

     

    Please see this article, it helped me:

    https://murggu.medium.com/databricks-and-fabric-writing-to-onelake-and-adls-gen2-671dcf24cf33

     

    So, to write to a table (new or existing) in a Lakehouse in another workspace, I think it is possible to write it like this:

    df.write.format("delta").mode("append").save(f"abfss://{workspace_name}@onelake.dfs.fabric.microsoft.com/{lakehouse_name}.Lakehouse/Tables/{table_name}")
     
    or if your objects names have special characters or whitespace, could use the id's:
     
    df.write.format("delta").mode("append").save(f"abfss://{workspace_id}@onelake.dfs.fabric.microsoft.com/{lakehouse_id}/Tables/{table_name}")
     
     
    For reading you could also use the fully qualified path, as you have already done. Then I think the whole process should be independent of the default lakehouse.