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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
akaur
Regular Visitor

How do I query custom schemas in lakehouses using sql magic cell ?

I am unable to query it using sql magic cell. I verified the schema and the table below exists in this lakehouse. I got this error with 

 

%%sql  

 select * from sampleLAKEHOUSE.AJ.tblFacility   ;
 

[TABLE_OR_VIEW_NOT_FOUND] The table or view `sampleLAKEHOUSE`.`AJ`.`tblFacility` cannot be found. Verify the spelling and correctness of the schema and catalog. If you did not qualify the name with a schema, verify the current_schema() output, or qualify the name with the correct schema and catalog. To tolerate the error on drop use DROP VIEW IF EXISTS or DROP TABLE IF EXISTS.; line 1 pos 14; 'Project [*] +- 'UnresolvedRelation [sampleLAKEHOUSE, AJ, tblFacility], [], false

 

 

however, I am able to view this same data with dataframes and with sql endpoint 

 

1 ACCEPTED SOLUTION
v-menakakota
Community Support
Community Support

Hi @akaur ,

May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

Thank you.

View solution in original post

8 REPLIES 8
nilendraFabric
Super User
Super User

@akaur You accepted the followup thread rather than real the solution. 🙂

v-menakakota
Community Support
Community Support

Hi @akaur ,

May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

Thank you.

this isnt resolved yet. I can do cross workspace but calling custom schema in LH using spark sql does not work. I can only do dbo. but I will mark it complete as its still in preview 

v-menakakota
Community Support
Community Support

Hi @akaur ,

As @nilendraFabric  mentioned,it is in preview. Thank you for the documentation. If the response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.

Regards,
Menaka.

nilendraFabric
Super User
Super User

Read this for more details, remember this is in preview, so there may be limitations and bugs

 

https://learn.microsoft.com/en-us/fabric/data-engineering/lakehouse-schemas

nilendraFabric
Super User
Super User

hello @akaur 

 

Try this

 

 

%%sql
SELECT *
FROM YourWorkspace.SampleLakehouse.AJ.tblFacility



If the default lakehouse or schema isn’t set, you must either specify the lakehouse name in your query or explicitly set it before running the query.

 

 

see if this works 

 

thanks

 

So far I have tried workspace.lakehuse.schema.tablename , doesnt work. 

I have tried USE SCHEMA and then queried, doesnt work

I have confirmed dbo schemas can be queried but not custom ones. 

Interesting @akaur  , just to make sure you have read rights to this ws and table

 

 

 

MS doc says 

 

Cross-workspace Spark SQL queries

Use the namespace "workspace.lakehouse.schema.table” to refer to tables in your code. This way, you can join tables from different workspaces if the user who runs the code has permission to access the tables.

 
SELECT * 
    FROM operations.hr.hrm.employees as employees 
    INNER JOIN global.corporate.company.departments as departments
    ON employees.deptno = departments.deptno;

 

 

If this don't work please raise a support ticket with MS

 

Please accept this answer if this is useful. So community users can find the right information quickly 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June FBC25 Carousel

Fabric Monthly Update - June 2025

Check out the June 2025 Fabric update to learn about new features.