I have already created a table in hbase using hive:
hive> CREATE TABLE hbase_table_emp(id int, name string, role string)
STORED BY \'org.apache.hadoop.hi
You can use the get_json_object
function to parse the data as a JSON object. For instance, if you create a staging table with your JSON data:
DROP TABLE IF EXISTS staging;
CREATE TABLE staging (json STRING);
LOAD DATA LOCAL INPATH '/local/path/to/jsonfile' INTO TABLE staging;
Then use get_json_object
to extract the attributes you want to load into the table:
INSERT OVERWRITE TABLE hbase_table_emp SELECT
get_json_object(json, "$.id") AS id,
get_json_object(json, "$.name") AS name,
get_json_object(json, "$.role") AS role
FROM staging;
There is more comprehensive discussion of this function here.