Forum Discussion
Shared SQL logic across workspace in Fabric
- 1 year ago
Hi 1maximax1,
Thanks for reaching out to Microsoft forum community.
We appreciate your efforts and thank you for sharing the update on the issue. Could you please confirm if your query has been resolved? If so, kindly mark the helpful response and accept it as the solution. This will help other community members resolve similar issues more efficiently.
Thank you.
hello 1maximax1
you can query view using Spark SQL and load the results into a DataFrame
df = spark.sql("SELECT * FROM your_view_name")
If you need to access a view from another Lakehouse, you might need to consider this :
1. Creating a shortcut to the underlying table(s) that the view is based on.
2. Recreating the view logic in your current Lakehouse.
3. Using Spark SQL to query the view in the source Lakehouse and then working with the resulting DataFrame
Please accept this as solution and give kudos if this resolved the query
Thank you very much for the quick response!
Your suggestion for accessing a view from another Lakehouse makes sense!
For reading the view to the Spark datafram, I don't think below code works. This approch only works for table.
df = spark.sql("SELECT * FROM your_view_name")
I found a way to read the view to dataframe in this blog.
https://fabric.guru/querying-sql-endpoint-of-fabric-lakehousewarehouse-in-a-notebook-with-t-sql
- nilendraFabric1 year agoSuper User
Thanks for getting back 1maximax1
If this all works could you please accept the solution, so other users in community can be benefited
- v-saisrao-msft1 year agoCommunity Support
Hi 1maximax1,
Thanks for reaching out to Microsoft forum community.
We appreciate your efforts and thank you for sharing the update on the issue. Could you please confirm if your query has been resolved? If so, kindly mark the helpful response and accept it as the solution. This will help other community members resolve similar issues more efficiently.
Thank you.