Hive資料型別

2021-07-11 20:07:58 字數 985 閱讀 7986

1、基本資料型別

包含如下型別:

整數型別:tinyint/smallint/int/bigint

浮點型別:float/double

布林型別:boolean

字串型別:string

舉例:

create table person

> (pid int,

> pname string,

> married boolean,

> salary double);

2、複雜資料型別

(1)array陣列

資料型別相同的元素集合。

create table student

(sid int,

sname string,

grade array);

其中array代表各科成績,比如:

(2)map

key和value對:

create table student2

(sid int,

sname string,

grade map);

其中map指的是學科對應的成績,比如:

上面的array和map可以組合起來使用,乙個人的各科成績:

hive> create table student3

> (sid int,

> sname string,

> grades array>);

(3)struct

結構體:

create table student4

> (sid int,

> info struct);

比如:

}3、時間型別

分為timestamp和date型別。

關於資料型別的介紹,可以參考文件: 

Hive資料型別

hive的內建資料型別可以分為兩大類 1 基礎資料型別 2 複雜資料型別。資料型別 所佔位元組 開始支援版本 tinyint 1byte,128 127 smallint 2byte,32,768 32,767 int4byte,2,147,483,648 2,147,483,647 bigint ...

Hive資料型別

列型別 hive支援的資料型別如下 原生資料型別 復合型別 支援傳統的unix時間戳,可選的納秒級精度。支援的轉換 時間戳被解釋是與timezone無關,儲存為從unix紀元的偏移量。提供便利的udf和時區轉換 to utc timestamp,from utc timestamp 所有現有date...

Hive資料型別

常用的基本資料型別 基本資料型別 所佔位元組 intboolean float double string 複雜資料型別 複雜資料型別 說明array array型別是由一系列相同資料型別的元素組成。並且可以通過下表來進行訪問。注意 下表從0開始計 mapmap包含key value鍵值對,可以通過...