Cloudera CDH/CDP 및 Hadoop EcoSystem, Semantic IoT등의 개발/운영 기술을 정리합니다. gooper@gooper.com로 문의 주세요.
---------------------------파일내용-------------
1, read a book
2,한글과 컴퓨터 만!~쉐
3,write a book
--------------------hive테이블 생성 --------------------
create external table cmt
(
c_id int,
c_cont string
)
row format delimited fields terminated by ','
location '/user/hadoop/input/exp';
-----------------------------cmt테이블내용-----------------
c_id c_conts
1 read a book
2 대한 민국 만!~쉐
3 write a book
----hive query --
select c_id, c_conts from cmt
lateral view explode(split(trim(c_cont),' ')) dummy as c_conts
==>
c_id c_conts
1 read
1 a
1 book
2 한글과
2 컴퓨터
2 만!~쉐
3 write
3 a
3 book
Time taken: 19.293 seconds, Fetched: 9 row(s)
-----------------------쿼리2-----------------
select c_id, c_conts from cmt
lateral view explode(split(c_cont, ' ')) dummy as c_conts
==>
c_id c_conts
1
1 read
1 a
1 book
2 한글과
2 컴퓨터
2 만!~쉐
3 write
3 a
3 book
Time taken: 18.142 seconds, Fetched: 10 row(s)