Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Data type of hive

Shulou Source: shulou.com Published: 2022-06-03 03:13:55 09月29日 Update

1. Basic data type

Because hive is also written in java, its basic data types are roughly the same as those of java:

two。 Basic data type (1) array (array)

Features: the number can be different, but the type is the same.

Example: take the family table (name string familes array) as an example:

# Table creation statement: create table t_family (name string, familes array) row format delimited fields terminated by'\ t 'collection items terminated by','; # query select * from t_family

# query a select name in the array, familes [0] from t_family

(2) map-mapping

Features: key-value can be different, the number can also be different

Data format: zs age:28,salary:20000,address:beijing

# Table creation statement: create table user_info (name string,info map) row format delimieted fields terminated by'\ t 'collection items terminated by', 'map keys terminated by':'# query statement select * from user_info

# query the key values of specific map select name, info ['age'], info [' salary'] from user_info

(3) struct type-object

Features: same number, same type

Example:

Take stu (name, info) as an example

Data format: zss 26, 123456, Shanghai.695

# Table creation statement: `create table stu_info (name string, info struct) row format delimted fields terminated by'\ t 'collection items terminated by', ``# query statement select * from stu_info

# query select name,info.address from stu_info for specific object attributes

Tags: Type same query data statement number feature object array format different attribute language Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Apple Microsoft Redmi Huawei