国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > 綜合 > 正文

通過hive訪問hbase中的表

2024-07-21 02:52:28
字體:
來源:轉載
供稿:網友
在hbase中創(chuàng)建表后,我們只能在hbase shell中使用scan查詢數據,這對于熟悉SQL的使用者不怎么習慣,不過我們可以在hive中創(chuàng)建外部表來訪問hbase表中的數據,例子如下:1.這里hbase中的表oss_user_label_action_data已經存在=> #<#:0xd5a1b0>hbase(main):067:0> scan 'oss_user_label_action_data',LIMIT=>1ROW                                COLUMN+CELL                                                                                       201407|31130101|8613500000001     column=info:areacode, timestamp=1415243857802, value=22                                           201407|31130101|8613500000001     column=info:cardtype, timestamp=1415243857802, value=1                                            201407|31130101|8613500000001     column=info:createtime, timestamp=1415243857802, value=20141028 11:18:34                          201407|31130101|8613500000001     column=info:enable_flag, timestamp=1415243857802, value=0                                         201407|31130101|8613500000001     column=info:extstring, timestamp=1415243857802, value=                                            201407|31130101|8613500000001     column=info:labelno, timestamp=1415243857802, value=31130101                                      201407|31130101|8613500000001     column=info:labelvalue, timestamp=1415243857802, value=9693                                       201407|31130101|8613500000001     column=info:modifytime, timestamp=1415243857802, value=20141028 11:18:45                          201407|31130101|8613500000001     column=info:monthno, timestamp=1415243857802, value=201407                                        201407|31130101|8613500000001     column=info:PRovcode, timestamp=1415243857802, value=1                                            201407|31130101|8613500000001     column=info:usernumber, timestamp=1415243857802, value=8613500000001                             1 row(s) in 0.0580 seconds2.創(chuàng)建外部表CREATE EXTERNAL TABLE hive_oss_user_label_action_data(key string, monthno string,usernumber string,labelno string,labelvalue string,provcode string,areacode string,cardtype string,extstring string,createtime string,modifytime string) STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' WITH SERDEPROPERTIES("hbase.columns.mapping" = ":key,info:monthno,info:usernumber,info:labelno,info:labelvalue,info:provcode,info:areacode,info:cardtype,info:extstring,info:createtime,info:modifytime")TBLPROPERTIES("hbase.table.name" = "oss_user_label_action_data");注意hbase.columns.mapping后面的字段直接不能出現空格和換行.3.通過hive查詢數據根據rowkey查詢select * from hive_oss_user_label_action_data where key='201407|31130101|8613500000001'根據某個字段查詢select * from hive_oss_user_label_action_data where usernumber='8613500000001'組合查詢select * from hive_oss_user_label_action_data where usernumber='8613500000001' and labelno='31130101'說明:這里我們訪問的hive_oss_user_label_action_data表是虛表,數據是存儲在hbase中的,我們可以創(chuàng)建另外一個hive中的表,將hbase中的數據加載到hive本地創(chuàng)建另外一個表CREATE TABLE hive_oss_user_label_action_data_local(key string, monthno string,usernumber string,labelno string,labelvalue string,provcode string,areacode string,cardtype string,extstring string,createtime string,modifytime string)ROW FORMAT DELIMITEDFIELDS TERMINATED BY '/t'STORED AS TEXTFILE;將hbase中的表數據加載到本地表INSERT OVERWRITE TABLE hive_oss_user_label_action_data_local SELECT * FROM hive_oss_user_label_action_data;-- The End --
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 扬州市| 滨州市| 滦平县| 聂荣县| 黎城县| 潜山县| 襄垣县| 昆明市| 三明市| 白沙| 泽普县| 金寨县| 莒南县| 绥江县| 鄂尔多斯市| 惠来县| 临夏市| 射洪县| 龙陵县| 蒙阴县| 行唐县| 汨罗市| 庆安县| 白水县| 日照市| 黑龙江省| 涿鹿县| 东安县| 商南县| 梁平县| 射阳县| 平乡县| 霞浦县| 弋阳县| 晋江市| 东光县| 阜城县| 万年县| 上虞市| 商丘市| 资阳市|