Forum Discussion
How do I query custom schemas in lakehouses using sql magic cell ?
- 1 year ago
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.
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.
- nilendraFabric1 year ago
Super User
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