When you apply for clusters in E-MapReduce, you are provided with a Hive environment by default. Using Hive, you cancreate and operate tables and data.
- Prepare the Hive script in advance. For example:
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;
- Save this script into a script file, such as uservisits_aggre_hdfs.hive, and upload it to an OSS directory (for example, oss://path/to/uservisits_aggre_hdfs.hive).
- Log on to the Alibaba Cloud E-MapReduce console.
- At the top of the navigation bar, click Data Platform.
- In the Actions column, click Design Workflownext to the specified project.
- On the left of the Job Editing page, right-click the folder you want to operate and select New Job.
- In the New Job dialog box, enter the job name and description.
- Select the Hive job type to create a Hive job. This type of job is submitted in the
background using the following method.
hive [user provided parameters]
- Click OK.
Note You can also create subfolders, rename folders, and delete folders by right-clicking on them.
- Enter the parameters in the Content field after the Hive commands. For example, if you want to use a Hive script uploaded
to OSS, enter the following.
You can also click Select OSS path to view and select from OSS. The system will automatically complete the path of the Hive script on OSS. Switch the Hive script prefix to ossref by clickingSwitch resource type. This ensures that the file is correctly downloaded by E-MapReduce.
- Click Save to complete the Hive job configuration.