How to read a Lakehouse table in another App Workspace – Microsoft Fabric – FourMoo | Fabric


I was doing some work recently for a customer and they had data stored in different Lakehouse’s which was in a different App Workspace.

I was pleasantly surprised that this can be quite easy to do.

In my example below I am going to show you how in my notebook I can read a table in a Lakehouse table when it is not attached to any Lakehouse.

NOTE: You could also use this pattern below to write to a Lakehouse table in a different App Workspace. You would just need to point to where you are writing to.

I promise you that the image below is real, and I have no Lakehouse attached to my notebook.

A screenshot of a computer

Description automatically generated

The first thing I did was to load the mssparkutils, this will be used in the later steps below.

A close up of text

Description automatically generated

Next, I went and got the name of my Lakehouse which has the table I wanted to read from.

In my example the Lakehouse name is “FM_LH”

I then used the following code below to get the LakehouseID and the App WorkspaceID.

NOTE: The reason I wanted to use the IDs for the Lakehouse and App Workspace is there are reserved characters in the names, and this can quite often result in errors when running the notebook. I suggest this as a way of working to ensure that it will always run as expected.

A screenshot of a computer

Description automatically generated

I could then see in the results as shown above.

Here is the table in my Source Lakehouse.

A screenshot of a computer

Description automatically generated

The final code cell was for me to read the source table in the Lakehouse with the code as explained below.

A screen shot of a computer

Description automatically generated

And here is the output.

A screenshot of a computer

Description automatically generated

In this blog post I have shown you how I can read a table from another App Workspace and Lakehouse.

Thanks for reading I hope you found this useful.

If you want a copy of the notebook, you can get it here: Fabric/Reading Table from Another Lakehouse.ipynb at main · GilbertQue/Fabric (github.com)



Source link

Be the first to comment

Leave a Reply

Your email address will not be published.


*