Allowing Users with Select Permission to View the Table Structure
Scenario
In the default Hive permission control logic, users who have only the SELECT permission on a table can query table data but cannot obtain table structure information (such as table definition, storage format, and partition information). This may bring inconvenience to data development, analysis, and debugging. For example, if a data analyst needs to compile query statements based on the table structure design, the data analyst needs to apply for higher permissions.
This section describes how to add custom parameters to allow users to view the table structure by running the show create table command after being granted the select permission.
Notes and Constraints
- This section applies only to clusters with Kerberos authentication enabled.
- This section applies only to the scenario where Ranger authentication is not enabled for Hive and HDFS.
Procedure
- Log in to the node where the client is installed as the client installation user.
For details about how to download and install the cluster client, see Installing an MRS Cluster Client.
- Go to the client installation directory, configure environment variables, and authenticate the user.
- Go to the client installation directory.
cd /opt/hadoopclient
- Configure environment variables.
source bigdata_env
- Authenticate the user. The user must have the permission to create Hive tables. Skip this step for clusters with Kerberos authentication disabled.
kinit Component service user
Example:
kinit test
- Go to the client installation directory.
- Log in to the Hive client.
beeline
- Create a table, for example, test.
create table test(name string);
- Insert data into the table.
insert into table test(name) values("A");
- Exit the Hive client.
!q
- Log in to the Hive client as the other user, for example, test1, by referring to 2 to 3. Run the following command to view the table structure created in 4:
show create table test;
After the command is executed, an error message is displayed, indicating that the user does not have the required permission.
Figure 1 Insufficient permissions reported - Log in to FusionInsight Manager, choose Cluster > Services > Hive, click Configurations, and click All Configurations.
- Choose HiveServer(Role) > Customization, add a custom parameter to the hive-site.xml parameter file, set Name to hive.allow.show.create.table.in.select.nogrant, and set Value to true.
- Click Save to save the settings. Click Instances, select all Hive instances, click More then Restart Instance, enter the user password, and click OK to restart all Hive instances.
- Determine whether to enable this function on the Spark/Spark2x client.
- If yes, download and install the Spark/Spark2x client again.
- If no, no further action is required.
- Bind the role that has the select permission on the table to the user who views the table. For details, see Creating a Hive User and Binding the User to a Role.
- Run the following command on the Hive client to view the table structure created in 4:
show create table test;
Figure 2 Viewing the table structure
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot