7 Mapping the Hive Data Model to the Oracle NoSQL Database Table Model
As the examples presented here demonstrate, in order to execute a Hive query against data stored in an Oracle NoSQL Database table, a Hive external table must be created with a schema mapped from the schema of the desired Oracle NoSQL Database table. This is accomplished by applying the mapping described here.
ObjectInspector
interface are used in the deserialization process to convert the associated data type defined by the Oracle NoSQL Database table model to its corresponding type in the Hive data model. See oracle.kv.hadoop.hive.table.
oracle.kv.hadoop.hive.table.TableBinaryObjectInspector
oracle.kv.hadoop.hive.table.TableBooleanObjectInspector
oracle.kv.hadoop.hive.table.TableDoubleObjectInspector
oracle.kv.hadoop.hive.table.TableFloatObjectorInspector
oracle.kv.hadoop.hive.table.TableIntObjectInspector
oracle.kv.hadoop.hive.table.TableLongObjectInspector
oracle.kv.hadoop.hive.table.TableJsonObjectInspector
oracle.kv.hadoop.hive.table.TableNumberObjectInspector
oracle.kv.hadoop.hive.table.TableTimestampObjectInspector
oracle.kv.hadoop.hive.table.TableEnumObjectInspector
oracle.kv.hadoop.hive.table.TableArrayObjectInspector
oracle.kv.hadoop.hive.table.TableMapObjectInspector
oracle.kv.hadoop.hive.table.TableRecordObjectInspector
The data model defined by the Oracle NoSQL Database (see oracle.kv.table.FieldDef.Type) is mapped to a subset of the types defined by Hive, as shown in the following table. Specifically, when creating a Hive external table so that you can query the data in a given Oracle NoSQL Database table, the Hive table must be created with a schema consistent with the mappings shown in the following table:
Table 7-1 Hive Data Model
Oracle NoSQL Database Type | Hive Type |
---|---|
FieldDef.Type.STRING | STRING |
CHAR | |
VARCHAR | |
FieldDef.Type.JSON | STRING |
FieldDef.Type.BOOLEAN | BOOLEAN |
FieldDef.Type.BINARY | BINARY |
FieldDef.Type.FIXED_BINARY | BINARY |
TINYINT | |
SMALLINT | |
FieldDef.Type.INTEGER | INT |
FieldDef.Type.LONG | BIGINT |
FieldDef.Type.FLOAT | FLOAT |
FieldDef.Type.NUMBER | DECIMAL |
FieldDef.Type.DOUBLE | DOUBLE |
FieldDef.Type.ENUM | STRING |
FieldDef.Type.TIMESTAMP | java.sql.TIMESTAMP |
DATE | |
FieldDef.Type.ARRAY | ARRAY |
FieldDef.Type.MAP | MAP<STRING, data_type> |
FieldDef.Type.RECORD | STRUCT<col_name : data_type,…> |
UNIONTYPE<data_type,data_type,…> |
For more details, see FieldDef.Type.
It is important to understand that when using Hive to query data in an Oracle NoSQL Database table, the schema of the Hive external table you create is dependent on the schema of the corresponding Oracle NoSQL Database table you wish to query. Thus, if you create a Hive external table with a schema that includes a Hive data type that is not mapped from an Oracle NoSQL Database FieldDef.Type
, then an error will occur when any attempt is made to query the table.