I want to restrict the access rights of different users through the standard SQL permission control that comes with Hive, but I don't know that if you can batch authorize tables under a certain database, you can only authorize one table at a time.

Using grant select on table table_name to user user_name and grant select on table table_name to role role_name in Hive gives table permissions, and table can be queried. However, using the permissions granted to the database by grant select on database database_name to user user_name or grant select on database database_name to role role_name, you cannot query the tables under that database. The error message is :

Error: Error while compiling statement: FAILED: HiveAccessControlException Permission denied: Principal [name=test, type=USER] does not have following privileges for operation QUERY [[SELECT] on Object [type=TABLE_OR_VIEW, name=test.wenxc]] (state=42000,code=40000)

grant message:

+-----------+--------+------------+---------+-----------------+-----------------+------------+---------------+----------------+----------+
| database  | table  | partition  | column  | principal_name  | principal_type  | privilege  | grant_option  |   grant_time   | grantor  |
+-----------+--------+------------+---------+-----------------+-----------------+------------+---------------+----------------+----------+
| test      |        |            |         | test            | USER            | DELETE     | false         | 1686816464000  | cocdkl   |
| test      |        |            |         | test            | USER            | INSERT     | false         | 1686816464000  | cocdkl   |
| test      |        |            |         | test            | USER            | SELECT     | false         | 1686816464000  | cocdkl   |
| test      |        |            |         | test            | USER            | UPDATE     | false         | 1686816464000  | cocdkl   |
+-----------+--------+------------+---------+-----------------+-----------------+------------+---------------+----------------+----------+

Hopefully, grant select on database database_name to role role_name will take effect.

0

There are 0 best solutions below