测试几种存储格式:
1. mkdir /usr/local/soft/hive-3.1.2/data/
2. 上传数据至data目录中
3.创建TEXTFILE学生信息表
create table students(
id bigint comment '学生id',
name string comment '学生姓名',
age int comment '学生年龄',
gender string comment '学生性别',
clazz string comment '学生班级'
) comment '学生信息表'
ROW FORMAT DELIMITED FIELDS TERMINATED BY ','
STORED AS TEXTFILE;
4.上传数据至HDFS
dfs -put /usr/local/soft/hive-3.1.2/data/ /user/hive/warehouse/filetest.db/students
5.通过查看HDFS路径可以看到数据大小没有发生变化 大小为37M
6.创建RCFile格式的学生信息表
create table students_rcFile(
id bigint comment '学生id',
name string comment '学生姓名',
age int comment '学生年龄',
gender string comment '学生性别',
clazz string comment '学生班级'
) comment '学生信息表'
ROW FORMAT DELIMITED FIELDS TERMINATED BY ','
STORED AS RCFile;
7.插入数据:
insert into table students_rcFile select * from students;
8.通过查看HDFS路径可以看到数据经过压缩大小为26.44 M
9.创建ORCFile格式的学生信息表
create table students_orc(
id bigint comment '学生id',
name string comment '学生姓名',
age int comment '学生年龄',
gender string comment '学生性别',
clazz string comment '学生班级'
) comment '学生信息表'
ROW FORMAT DELIMITED FIELDS TERMINATED BY ','
STORED AS ORC;
10.插入数据:
insert into table students_orc select * from students;
11.通过查看HDFS路径可以看到数据经过压缩大小为 220.38 KB,同时插入数据时与RCFile格式时间相差不大
12.创建Parquet格式的学生信息表
create table students_parquet(
id bigint comment '学生id',
name string comment '学生姓名',
age int comment '学生年龄',
gender string comment '学生性别',
clazz string comment '学生班级'
) comment '学生信息表'
ROW FORMAT DELIMITED FIELDS TERMIN