Databricks Error in SQL statement: SecurityException: User does not have permission SELECT on table

430 views Asked by At

I am still getting familiar with the new Databricks Notebook.

When I enter the SQL code:

CREATE OR REPLACE VIEW mydatabase.mytable 

AS 

SELECT 
  pers.first_name as first_name,
  pers.last_name as last_name,
  r.role_code as role_code,
 FROM 
  product_master
  INNER JOIN global.date_dim dd on dd.date_key = ptplf.date_key

(I have omitted a lot of the code for brevity)

I get the error:

Error in SQL statement: SecurityException: User cannot SELECT on table `mydatabase`.`mytable` because:
--The owner of table `global`.`date_dim` is different from the owner of table `mydatabase`.`mytable`.

It would appear the issue is on security

1

There are 1 answers

0
Bhavani On BEST ANSWER

Ensure that you have permission to read data from mydatabase.mytable. If not, obtain permission from the admin to read data from mydatabase.mytable by following the procedure below:

In the SQL editor, select the database, right-click on the database, and choose open in catalog explorer as shown below:

enter image description here

This will open the Catalog window. Select the table, navigate to permissions, click on 'grant', select the user, and click on the SELECT permission before clicking 'grant' as shown below:

enter image description here

This will grant the user access to read data from the table.