GRANT Statement (Impala 2.0 or higher only)
The
GRANT statement grants a privilege on a specified object
to a role or grants a role to a group.
Syntax:
GRANT ROLE role_name TO GROUP group_name
GRANT privilege ON object_type object_name
TO [ROLE] roleName
[WITH GRANT OPTION]
privilege ::= ALL | ALTER | CREATE | DROP | INSERT | REFRESH | SELECT | SELECT(column_name)
object_type ::= TABLE | DATABASE | SERVER | URI
Typically, the object name is an identifier. For URIs, it is a string literal.
Required privileges:
Only administrative users (initially, a predefined set of users specified in the Sentry service configuration file) can use this statement.
Only Sentry administrative users can grant roles to a group.
The WITH GRANT OPTION clause allows members of the
specified role to issue GRANT and REVOKE
statements for those same privileges Hence, if a role has the
ALL privilege on a database and the WITH GRANT
OPTION set, users granted that role can execute
GRANT/REVOKE statements only for that
database or child tables of the database. This means a user could revoke
the privileges of the user that provided them the GRANT
OPTION.
Impala does not currently support revoking only the WITH GRANT
OPTION from a privilege previously granted to a role. To remove
the WITH GRANT OPTION, revoke the privilege and grant it
again without the WITH GRANT OPTION flag.
The ability to grant or revoke SELECT privilege on specific columns is available
in Impala 2.3 and higher. See the documentation for Apache Sentry for details.
Usage notes:
You can only grant the ALL privilege to the
URI object. Finer-grained privileges mentioned below on
a URI are not supported.
| Privilege | Scope | SQL Allowed to Execute |
|---|---|---|
REFRESH |
SERVER |
INVALIDATE METADATA on all tables in all
databases
|
REFRESH |
DATABASE |
INVALIDATE METADATA on all tables in the
named database
|
REFRESH |
TABLE |
INVALIDATE METADATA on the named
table
|
CREATE |
SERVER |
CREATE DATABASE on all
databases
|
CREATE |
DATABASE |
CREATE TABLE on all tables in the named
database |
DROP |
SERVER |
DROP DATBASE on all databases
|
DROP |
DATABASE |
DROP DATABASE on the named
database
|
DROP |
TABLE |
DROP TABLE on the named table |
ALTER |
SERVER |
ALTER TABLE on all tables |
ALTER |
DATABASE |
ALTER TABLE on the tables in the named
database |
ALTER |
TABLE |
ALTER TABLE on the named table |
-
ALTER TABLE RENAMErequires theALTERprivilege at theTABLElevel and theCREATEprivilege at theDATABASElevel. -
CREATE TABLE AS SELECTrequires theCREATEprivilege on the database that should contain the new table and theSELECTprivilege on the tables referenced in the query portion of the statement. -
COMPUTE STATSrequires theALTERandSELECTprivileges on the target table.
Compatibility:
-
The Impala
GRANTandREVOKEstatements are available in Impala 2.0 and later. -
In Impala 1.4 and later, Impala can make use of any roles and privileges specified by the
GRANTandREVOKEstatements in Hive, when your system is configured to use the Sentry service instead of the file-based policy mechanism. -
The Impala
GRANTandREVOKEstatements for privileges do not require theROLEkeyword to be repeated before each role name, unlike the equivalent Hive statements. -
Currently, each Impala
GRANTorREVOKEstatement can only grant or revoke a single privilege to or from a single role.
Cancellation: Cannot be cancelled.
HDFS permissions: This statement does not touch any HDFS files or directories, therefore no HDFS permissions are required.
Kudu considerations:
-
Only users with the
ALLprivilege onSERVERcan create external Kudu tables. -
The
ALLprivileges onSERVERis required to specify thekudu.master_addressesproperty in theCREATE TABLEstatements for managed tables as well as external tables. - Access to Kudu tables is enforced at the table level and at the column level.
-
The
SELECT- andINSERT-specific permissions are supported. -
The
DELETE,UPDATE, andUPSERToperations require theALLprivilege.
Related information:
Enabling Sentry Authorization for Impala, REVOKE Statement (Impala 2.0 or higher only), CREATE ROLE Statement (Impala 2.0 or higher only), DROP ROLE Statement (Impala 2.0 or higher only), SHOW Statement