Mapping a Hive External Table to exampleJsonTable: Non-Secure Store

Assuming you have executed the initial steps to deploy a non-secure store, followed the directions presented in the Creating and Populating the exampleJsonTable appendix to create and populate the Oracle NoSQL Database table named exampleJsonTable, and configured the Hive client environment for interaction with Oracle NoSQL Database, you can then create an external Hive table that maps to that Oracle NoSQL Database table by executing the following Hive command:

CREATE EXTERNAL TABLE IF NOT EXISTS exampleJsonTable
    (id INT, jsonfield STRING)
    COMMENT 'Hive mapped to NoSQL table: exampleJsonTable'
    STORED BY 'oracle.kv.hadoop.hive.table.TableStorageHandler'
    TBLPROPERTIES (
        "oracle.kv.kvstore" = "example-store", 
        "oracle.kv.hosts"= "kv-host-1:5000,kv-host-2:5000,kv-host-3:5000", 
        "oracle.kv.tableName" = "exampleJsonTable", 
        "oracle.kv.hadoop.hosts” = "dn-host-1,dn-host-2,dn-host-3");

The command above applies the required data model mapping to create a Hive table named exampleJsonTable with columns whose types are consistent with the corresponding fields of the Oracle NoSQL Database table specified via the oracle.kv.tableName property.

Although not necessary, the Hive table that is created is given the same name as the table to which it is mapped in the store.