網(wǎng)絡(luò)日志的Hive簡單查詢

測試數(shù)據(jù)

[root@master hive]# cat ./tmp_data/weblog.data
1c13c719fbfd87f49522f189413c6ba /gybfokxyojgtwrq.html   2012-05-10  21:17:32    169.65.197.63
e42fe5714cb4402f81e5dce8da1755  /hpipbodlxgt.html   2012-05-10  21:12:04    166.22.84.135
[root@master hive]# cat ./tmp_data/ip_to_country.txt 
169.65.197.63   United States
166.22.84.135   United Kingdom

建表語句

[root@master hive]# cat /opt/weblog.hive 
create external table weblog_entries
( md5 string,
url string,
request_date string,
request_time string,
ip string
)
row format delimited fields terminated by '\t'
lines terminated by '\n'
location '/data/hive/weblog';
[root@master hive]# cat /opt/ip_to_country.hive 
create table ip_to_country(
ip string,
country string
)
row format delimited fields terminated by '\t'
lines terminated by '\n'
location '/data/hive/ip_to_country';

加載數(shù)據(jù)

hive> load data local inpath './tmp_data/weblog.data' into table weblog_entries;
hive> load data local inpath './tmp_data/ip_to_country.txt' into table ip_to_country;

連接查詢

hive> select wle.*, itc.country FROM weblog_entries wle join ip_to_country itc on wle.ip = itc.ip;

使用查詢結(jié)果創(chuàng)建新表

hive> create table weblog_entries_with_url_length as select url, request_date, request_time, length(url) as url_length from weblog_entries;
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • Spring Cloud為開發(fā)人員提供了快速構(gòu)建分布式系統(tǒng)中一些常見模式的工具(例如配置管理,服務(wù)發(fā)現(xiàn),斷路器,智...
    卡卡羅2017閱讀 136,534評論 19 139
  • Android 自定義View的各種姿勢1 Activity的顯示之ViewRootImpl詳解 Activity...
    passiontim閱讀 178,893評論 25 709
  • 是夜,牽著小糯米團(tuán)子的手行走于河邊,耳邊有微微的涼風(fēng)習(xí)習(xí),眼前是萬家的燈火?? 若不去想前塵后世,此一刻,人生于我...
    清江月閱讀 316評論 0 1
  • 第八章,投資者與市場波動(dòng) 1.在任何一個(gè)幾年的期限內(nèi),普通股組合幾乎必然會發(fā)生價(jià)值的波動(dòng)。應(yīng)了解這些可能發(fā)生的情況...
    新興市場的小邏輯閱讀 642評論 0 2
  • 這是補(bǔ)六月十六號的 嗯 今天呢 在觀看他們的大戰(zhàn) (⊙_⊙) 心中略有愧疚吧
    ABO_875b閱讀 207評論 0 0

友情鏈接更多精彩內(nèi)容