1
votes

I have an IBM cloud where I have Hive/Hbase, I just create a "table" on Hive and I also load some data from a csv file.

My csv file contains information from google play store apps.

My commands for creating and upload data to my table are the following ones:

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;

Ok, It works correctly and using a Select I obtain the data correctly.

Now what I want to do is to create a HBASE table, my problem is that I don't know how to do it correctly.

First of all I create a Hbase Db -> create google_db_ , google_data, info_data

Now I try to create an external table using this hive command, but what I am getting is an error that my table is not found.

This is the command I am using for the creation of the external hive table.

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_");

I don't know the correct way for the creation of Hbase table based on an Hive schema, for uploading correctly my .csv data.

Any idea ? I am new on it.

Thanks!

1

1 Answers

1
votes

Try with below create table statement in HBase,

Create Hbasetable:

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

Create Hive External table on Hbase:

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_");

Then insert data into Hive-Hbase table(uamibm130_hbase_google) from Hive table(app_desc).

Insert data into Hive-Hbase table:

Hive> insert into table uamibm130_hbase_google select * from app_desc;