Hive資料型別

2021-10-18 07:08:24 字數 1421 閱讀 6339

hive資料型別

長度例子

tinyint

1byte有符號整數

20smalint

2byte有符號整數

20int

4byte有符號整數

20bigint

8byte有符號整數

20boolean

布林型別,true或者false

true,false

float

單精度浮點數

3.14159

double

雙精度浮點數

3.14159

string

字元系列。可以指定字符集。可以使用單引號或者雙引號。

『now is the time』 「for all good men」

timestamp

時間型別

binary

位元組陣列

資料型別

描述語法示例

struct

和c語言中的struct類似,都可以通過「點」符號訪問元素內容。例如,如果某個列的資料型別是struct,那麼第1個元素可以通過欄位.first來引用。

struct()

map()

map是一組鍵-值對元組集合,使用陣列表示法可以訪問資料。例如,如果某個列的資料型別是map,其中鍵->值對是』first』->』john』和』last』->』doe』,那麼可以通過欄位名[『last』]獲取最後乙個元素

map()

array

陣列是一組具有相同型別和名稱的變數的集合。這些變數稱為陣列的元素,每個陣列元素都有乙個編號,編號從零開始。例如,陣列值為[『john』, 『doe』],那麼第2個元素可以通過陣列名[1]進行引用。

array()

"address":

}

songsong,bingbing_lili,xiao song:18_xiaoxiao song:19,hui long guan_beijing

yangyang,caicai_susu,xiao yang:18_xiaoxiao yang:19,chao yang_beijing

create table test(

name string,

friends array,

children map,

address struct)

row format delimited fields terminated by ','

collection items terminated by '_'

map keys terminated by ':'

lines terminated by '\n';

可以使用cast操作顯示進行資料型別轉換

Hive資料型別

1 基本資料型別 包含如下型別 整數型別 tinyint smallint int bigint 浮點型別 float double 布林型別 boolean 字串型別 string 舉例 create table person pid int,pname string,married boolea...

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...