Hive_Hive的数据类型

Hive Basic Data Type:

Basic Types:
tinyint/samllint/int/bigint
float/double
boolean
string

Complex Types:
Array
Map
Struct

Date Type:
Date
Timestamp

Create table:
create table person
(pid int,
pname string,
married boolean,
salary double);

Look table:
desc person;

different between varchar and char, char fix length, varchar variable length.
create table test1
(vname varchar(20),cname char(20));
desc test1;

=========================================================================================

Hive Complex Data Type:

Array:

create table student
(sid int,
sname string,
grade array<float>);
desc student;
{1,Tom,[99,100,98]}

Map:

create table student2
(sid int,
sname string,
grade map<string,float>);
desc student2;
{1,Tom,<'math',100>}

Combine:

create table student3
(sid int,
sname string,
grade array<map<string,float>>);
desc student3;
{1,Tom,[<'math',100>,<'english',100>]}

Struct:

create table student4
(sid int,
info struct<name:string,age:int,sex:string>)
desc student4;
{1,{'Tom', 10, 'boy'}}

=========================================================================================

Hive Date Data Type:

different between Date and Timestamp
Timestamp : timezoneless/offset
select unix_timestamp();

Dates: only to day, have not hour, min, second.
{YYYY-MM-DD} : '2012-01-01'

 

posted @ 2017-01-18 17:13  天天好心情啊  阅读(287)  评论(0编辑  收藏  举报