14. Pig
• 由Yahoo! 開發
• Scripting Language for Hadoop
• 提供Pig Latin 語言,在Grunt Shell 進行互動
• 透過一系列的Relation 宣告,對資料進行轉換,每個轉換都
是一個MapReduce Job
• 通常用在ETL 階段,將外部資料轉入Hadoop
14
15. Sqoop
• 取SQL to Hadoop 之意
• 由Cloudera 開發,現在是Apache 專案
• Get Data to/from SQL Database
• 是RDBMS 與Hadoop 間的匯入匯出工具
• 底層一樣是透過MapReduce 機制運作
• 提供一般的Connector,透過JDBC 建立Connection
• MySQL 與PostgreSQL 可以使用支援特殊語法的Fast
Connector
15
16. Hadoop Distribution
• Apache 有Apache BigTop
• Cloudera 有Cloudera Distribution for Hadoop (CDH)
• Oracle 有Oracle Big Data Appliance
• Intel 以前有Intel Distribution for Hadoop (IDH),現在是直接
與Cloudera 合作
• MapR 有MapR Distribution for Apache Hadoop (M3/M5/M7)
• Hortonworks 有Hortonworks Data Platform (HDP)
• Microsoft 有Microsoft HDInsight
• …
16
38. Hive 示範
create external table movies(title string, year string)
row format delimited
fields terminated by 't'
lines terminated by 'n';
location '/movies';
select count(*) from movies;
select title, size(split(title, ' ')) from movies
where year = 2000;
select year, count(*) from movies group by year;
drop table movies;
38
39. Hive 輸出檔案注意事項
insert overwrite directory 'moviesoutput'
select concat_ws(',', cast(size(split(title, ' ')) as string),
cast(count(*) as string))
from movies
group by size(split(title, ' '));
39
• 輸出放在/user/CLUSTER帳號目錄之下
• 檔名為000000_0、000001_0、…,視Reducer 數目而定
• 使用Unix 換行方式(n)
• 欄位分隔符號預設為^A (001),可以透過concat_ws 調整
• 欄位最好先透過cast 轉換型別為String,方便輸出