Configure a Hive job
Updated at:
E-MapReduce (EMR) provides a built-in Hive environment to create tables and manage data.
Prerequisites
- You have created a project. For more information, see project management.
- You have prepared a Hive SQL script and uploaded it to a directory in Object Storage Service (OSS), for example, oss://path/to/uservisits_aggre_hdfs.hive.The uservisits_aggre_hdfs.hive file contains the following code.
USE DEFAULT; DROP TABLE uservisits; CREATE EXTERNAL TABLE IF NOT EXISTS uservisits (sourceIP STRING,destURL STRING,visitDate STRING,adRevenue DOUBLE,userAgent STRING,countryCode STRING,languageCode STRING,searchWord STRING,duration INT) ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' STORED AS SEQUENCEFILE LOCATION '/HiBench/Aggregation/Input/uservisits'; DROP TABLE uservisits_aggre; CREATE EXTERNAL TABLE IF NOT EXISTS uservisits_aggre (sourceIP STRING, sumAdRevenue DOUBLE) STORED AS SEQUENCEFILE LOCATION '/HiBench/Aggregation/Output/uservisits_aggre'; INSERT OVERWRITE TABLE uservisits_aggre SELECT sourceIP, SUM(adRevenue) FROM uservisits GROUP BY sourceIP;
Procedure
-
Go to the Projects page in Data Platform.
-
Log in to the E-MapReduce console with your Alibaba Cloud account.
-
In the top navigation bar, select the region and resource group.
-
Click the Data Development tab.
-
-
In the row of the project you want to edit, click Edit Job.
- Create a Hive job.
- On the left side of the page, right-click the target folder and select Create Job.
- In the Create Job dialog box, enter a Job Name and Description. From the Job Type drop-down list, select Hive.
EMR submits this type of job by running the following command:
hive [user provided parameters] - Click OK.
- Edit the job content.
- In the Content field, enter the required command-line parameters.
For example, to use your Hive script from OSS, enter the following:
-f ossref://path/to/uservisits_aggre_hdfs.hiveNotepathis the OSS path to theuservisits_aggre_hdfs.hivefile.You can also click + Enter an OSS path at the bottom of the page to browse and select your file from OSS. The system automatically populates the script path. Ensure the path prefix is OSSREF so EMR can download the file correctly.
- Click Save.
- In the Content field, enter the required command-line parameters.
Is this page helpful?