目录
一:hive介绍
1.hive本质:将HQL转化为MapReduce程序
2.hive中select不走MR,走元数据
3.基本数据类型:INT,BIGINT,DOUBLE,STRING
hive的string类型相当于数据库中的varchar类型
4.hive中集合数据类型有
Map, Array, Struct
支持类型转换
二:创建测试表
create table test(
name string,
friends array<string>,
children map<string,int>,
address struct<street:string,city:string>
)
row format delimited fields terminated by ',' --列分隔符
collection items terminated by '_' -- 数据分隔符
map keys terminated by ':' -- map中key,value分隔符
lines terminated by '\n'; --行分隔符
导入文本数据到测试表
load data local inpath '/opt/module/hive/test.txt' into table test;
三:类型转换
可以使用cast('1' as INT)把字符串’1‘转换为整数1;如果强制类型转换失败
四:操作
1.上传文件到HDFS
dfs -put /opt/module/hive/data/student.txt /user/atgui