1. Experiment content: implement wordcount with hive
2. Experimental steps:
1. Prepare the data
First, use the vi editor to write a word.txt file with the content as shown in the figure below:
2. Start and create a test database, name test, enter the following command, as shown in the figure
bin/hive
create database test;
3. Create a table wordcount in the test database
create table wordcount(rowdata string);
4. Load data The
code is as follows
load data local inpath '/home/hadoop/word.txt' into table wordcount;
5. SQL programming to achieve WordCount
code is as follows:
select word ,count(1) cnt
from wordcount lateral view explode(split(rowdata," ")) alaistable as word
group by word
order by cnt ;
3. Experimental results
as the picture shows