由于很多數(shù)據(jù)在hadoop平臺(tái),當(dāng)從hadoop平臺(tái)的數(shù)據(jù)遷移到hive目錄下時(shí),由于hive默認(rèn)的分隔符是\,為了平滑遷移,需要在創(chuàng)建表格時(shí)
由于很多數(shù)據(jù)在Hadoop平臺(tái),當(dāng)從hadoop平臺(tái)的數(shù)據(jù)遷移到hive目錄下時(shí),由于hive默認(rèn)的分隔符是\,為了平滑遷移,需要在創(chuàng)建表格時(shí)指定數(shù)據(jù)的分割符號(hào),語(yǔ)法如下:
create table test(uid string,name string)row format delimited fields terminated by '\t';
通過(guò)這種方式,完成分隔符的指定。
然后通過(guò)hadoop fs -cp或者h(yuǎn)adoop distcp 進(jìn)行文件夾復(fù)制。
由于數(shù)據(jù)復(fù)制的成本比較高,時(shí)間比較慢,當(dāng)不需要復(fù)制數(shù)據(jù)的時(shí)候,可以直接采取移動(dòng)的方式將hadoop數(shù)據(jù)轉(zhuǎn)移到hive,,hadoop fs -mv src dest。
一個(gè)比較簡(jiǎn)單的方法是直接創(chuàng)建 external table,語(yǔ)法如下:
create table test(uid string,name string)row format delimited fields terminated by '\t' location 'hdfs';
通過(guò)這種方式,避免數(shù)據(jù)的移動(dòng)帶來(lái)時(shí)間損耗,提高運(yùn)行的效率。
聲明:本網(wǎng)頁(yè)內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問(wèn)題請(qǐng)及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com