Hive和Hbase表用于肝硬化

时间:2018-11-04 16:14:09

标签: hive hbase

我有一个IBM云,其中有Hive / Hbase,我只是在Hive上创建一个“表”,而且还从一个csv文件中加载了一些数据。

我的csv文件包含来自Google Play商店应用的信息。

我用于创建数据并将其上传到我的表的命令如下:

hive>     create table if not exists app_desc (name string,
          category string, rating int, 
          reviews int, installs string,
          type string, price int, 
          content string, genres string,
          last_update string, current_ver string, 
          android_ver string) 
    row format delimited fields terminated by ',';

hive > load data local inpath '/home/uamibm130/googleplaystore.csv' into table app_desc;

好的,它可以正常工作,并且使用Select我可以正确获取数据。

现在我要做的是创建一个HBASE表,我的问题是我不知道如何正确地做它。

首先,我创建一个Hbase Db->创建google_db_,google_data,info_data

现在我尝试使用此配置单元命令创建一个外部表,但是我得到的是一个错误,提示找不到我的表。

这是我用于创建外部配置单元表的命令。

create external table uamibm130_hbase_google (name string, category string, rating int, reviews int, installs string, type string, price int, content string, genres string, last_update string, current_ver string, android_ver string) 
        stored by 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key, 
    google_data:category,google_data:rating, info_data:reviews, 
    info_data:installs, info_data:type, info_data:price, info_data:content, 
    info_data:genres, info_data:last_update, info_data:current_ver, 
    info_data:android_ver") TBLPROPERTIES("hbase.table.name" = "google_db_");

我不知道基于Hive模式创建Hbase表的正确方法,无法正确上传我的.csv数据。

有什么主意吗?我是新来的。

谢谢!

1 个答案:

答案 0 :(得分:1)

尝试在HBase中使用以下create table语句,

创建Hbasetable:

hbase(main):001:0>create 'google_db_','google_data','info_data'

在Hbase上创建Hive外部表:

hive> create external table uamibm130_hbase_google (name string, category string, rating int, reviews int, installs string, type string, price int, content string, genres string, last_update string, current_ver string, android_ver string) 
     stored by 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key, 
    google_data:category,google_data:rating, info_data:reviews, 
    info_data:installs, info_data:type, info_data:price, info_data:content, 
    info_data:genres, info_data:last_update, info_data:current_ver, 
    info_data:android_ver") TBLPROPERTIES("hbase.table.name" = "google_db_",
    "hbase.mapred.output.outputtable" = "google_db_");

然后将数据从Hive-Hbase table(uamibm130_hbase_google)插入Hive table(app_desc)

将数据插入Hive-Hbase表:

Hive> insert into table uamibm130_hbase_google select * from app_desc;