Using Hue to Execute HiveQL
Scenario
Hue provides the Hive management UI to run HiveQL (HQL) statements and query Hive data.
Access Editor
- Access the Hue web UI. For details, see Accessing the Hue Web UI.
- In the navigation tree on the left, click
and choose Hive. The Hive page is displayed.
Hive supports the following functions:
- Running HQL statements
Select the target database on the left. You can also click
in the upper right corner and enter the target database name to search for the database.
Enter an HQL statement in the text box and click
or press Ctrl+Enter to run the HQL statement. The execution result is displayed on the Result tab page.
- Analyzing HQL statements
Select the target database on the left, enter the HQL statement in the text box, and click
to compile the HQL statement and check whether the statement is correct. The execution result is displayed under the text editing box.
- Saving HQL statements
Enter the HQL statement in the text box, click
in the upper right corner, and enter the name and description. You can view the saved statements in the Saved Queries tab.
- Viewing historical records
Click Query History to view the HQL status. You can view the history of all the statements or only the saved statements. If many historical records exist, you can enter keywords in the text box to search for desired records.
- Configuring advanced queries
Click
in the upper right corner to configure the file, function, and settings.
- Viewing the information of shortcut keys
Click
in the upper right corner to view information about all shortcut keys.
- Running HQL statements
How to Use Metadata Browser
Access the Hue web UI. For details, see Accessing the Hue Web UI.
- Viewing metadata of Hive tables
Click
in the navigation tree on the left and click a table name. The metadata of the Hive table is displayed.
- Managing metadata of Hive tables
On the metadata information page of a Hive table:
- Click Import in the upper right corner to import data.
- Click Overview to view the location of the table file in the Properties field.
View the field information of each column in a Hive table and manually add description information. Note that the added description information is not the field comments in the Hive table.
- Click Sample to browse data.
- Managing Hive metadata tables
Click
in the left list to create a table based on the uploaded file in the database. You can also manually create a table.
![](https://support.huaweicloud.com/intl/en-us/cmpntguide-lts-mrs/public_sys-resources/caution_3.0-en-us.png)
The Hue page is used to view and analyze data such as files and tables. Do not perform high-risk management operations such as deleting objects on the page. If such an operation is required, perform the operation on each component after confirming that the operation does not affect services. For example, use the HDFS client to perform operations on HDFS files and use the Hive client to perform operations on Hive tables.
Executing HQL Statements
- Select a Hive database from the Database drop-down list box. The default database is default.
The system displays all available tables. You can enter a keyword of the table name to search for the desired table.
- Click the desired table name. All columns in the table are displayed.
Move the cursor to the row where the table or column is located and click
. Column details are displayed.
- Enter the query statements in the area for editing HQL statements.
- Click
to execute the HQL statements.
Figure 1 Executing a statement- If you want to use the entered HQL statements again, click
to save them.
- Advanced query configuration:
Click
in the upper right corner to configure information such as files, functions, and settings.
- Viewing the information of shortcut keys:
Click
in the upper right corner to view the syntax and keyboard shortcut information.
- To delete an entered HQL statement, click the triangle next to
and select Clear.
- Viewing history:
Click Query History to view the HQL running status. You can view the history of all the statements or only the saved statements. If many historical records exist, you can enter keywords in the text box to search for desired records.
- If you want to use the entered HQL statements again, click
Viewing Execution Results
- View the execution results below the execution area on Hive. The Query History tab page is displayed by default.
- Click a result to view the execution result of the executed statement.
Hue does not support the display of a large amount of data. When a large number of SQL query results are loaded, the page may be frozen and some data may not be displayed. It is recommended that no more than 5,000 lines of query results be loaded.
Managing Query Statements
- Click Saved Queries.
- Click a saved statement. The system automatically adds the statement to the editing area.
Modifying the Session Configuration of the Hue Editor
- On the editor page, click
.
- Click
on the right of Files, and then click
to select files.
You can click
next to Files to add a file resource.
- In the Functions
area, enter a user-defined name and the class name of the function.
You can click
next to Functions to add a customized function.
- In the Settings
area, enter the Hive parameter name in the Key, and value in Value. The current Hive session connects to Hive based on the customized configuration.
You can click
to add a parameter.
Typical Scenario
On the Hue page, create a Hive table as follows:
- Click
at the upper left corner of Hue web UI and select the Hive instance to be operated to enter the Hive command execution page.
- Enter an HQL statement in the command input box, for example:
create table hue_table(id int,name string,company string) row format delimited fields terminated by ',' stored as textfile;
Click
to execute the HQL statements.
Figure 2 Executing a statement - Enter the following command in the command input box:
show tables;
Click
to view the created table hue_table in Result.
Figure 3 Viewing the result
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