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.
Hi nilendraFabric ,
Thank you very much for the reply and help on this topic! I want to get more clarification for the option #1 in your response.
In option 1, when you say SQL views, do you mean the view in the screenshot below?
Question 1. I found that I can't use the view in the notebook in pyspark. Is it possible to read the view into pyspark data frame?
Question 2. When I set up shortcut from another Lakehouse, I am not able to create shortcut for the view, the only option in the shortcut it to the table or file. Is it possible to create shortcut to the views?
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
- 1maximax11 year agoFrequent Visitor
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.