Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
dwpurdy
Frequent Visitor

Can you read a Fabric lakehouse view from spark?

I have a Fabric lake house with a view that I created via the T-SQL endpoint.  Can I query the view from a spark notebook?  If so how?

5 REPLIES 5
SorenSparso
Advocate I
Advocate I

Hi,

 

Has anyone found a solution/workaround for this? Due to the nature of the project, I have to use T-SQL, so writing the view definition SQL directly in the notebook wont work.

 

Thanks

puneetvijwani
Resolver IV
Resolver IV

@dwpurdy you should be using below way in your notebook cells to create and use that view logic and use as a source in notebook to write out as delta table 

%%sql
CREATE OR REPLACE TEMP VIEW Viewname AS
select statmenents 


PS:If my response helped, kindly select it as the solution. Your kudos are greatly appreciated!
dwpurdy
Frequent Visitor

Thanks for the work around, but I was trying to encapusulate transformation logic in T-SQL views and then use the views as sources to write out new delta tables wth a Spark script. 

 

It's hard to believe it's not possible to read a T-SQL view via the end point in Spark.  Does that also mean, I can't access warehouse tables in Spark via the warehouse SQL end point? 

 

This seems like a missing feature. In Synapse, it's easy to read a dedicated pool table in Spark.

It's not possible to read a T-SQL view from Spark. But it's possible to read a warehouse table using Spark. You just need to add the warehouse table as a shortcut and you can access those tables just like the other lakehouse tables. 

HimanshuS-msft
Community Support
Community Support

Hello @dwpurdy 

I did tried to access the views from a notebook and spark always complained that the object does not exists .

%%sql
SELECT * FROM view1

Error: Table or view not found: view1; line 1 pos 14;
'Project [*]
+- 'UnresolvedRelation [view1], [], false

So i am pretty sure that you cannot access from SPARK  . 

Since views are just SQL query  what you can do as work around is , run the SQL query itself 

 
%%sql
SELECT * FROM Address


Thanks
HImanshu

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

JanFabricDE_carousel

Fabric Monthly Update - January 2025

Explore the power of Python Notebooks in Fabric!

JanFabricDW_carousel

Fabric Monthly Update - January 2025

Unlock the latest Fabric Data Warehouse upgrades!

JanFabricDF_carousel

Fabric Monthly Update - January 2025

Take your data replication to the next level with Fabric's latest updates!