数据源地址:http://pan.baidu.com/s/1cKsrKi
1.准备数据源
打开 上牌数--商用车销量数据样例.xlsx,另存为car.txt文件,打开car.txt,设置编码格式为UTF-8,保存并上传至master节点。
2.创建car 数据库,建立car表,并上传数据
create external table cars(
province string, --省份
month int, --月
city string, --市
county string, --区县
year int, --年
cartype string,--车辆型号
productor string,--制造商
brand string, --品牌
mold string,--车辆类型
owner string,--所有权
nature string, --使用性质
number int,--数量
ftype string,--发动机型号
outv int,--排量
power double, --功率
fuel string,--燃料种类
length int,--车长
width int,--车宽
height int,--车高
xlength int,--厢长
xwidth int,--厢宽
xheight int,--厢高
count int,--轴数
base int,--轴距
front int,--前轮距
norm string,--轮胎规格
tnumber int,--轮胎数
total int,--总质量
curb int,--整备质量
hcurb int,--核定载质量
passenger string,--核定载客
zhcurb int,--准牵引质量
business string,--底盘企业
dtype string,--底盘品牌
fmold string,--底盘型号
fbusiness string,--发动机企业
name string,--车辆名称
age int,--年龄
sex string --性别
)
row format delimited
fields terminated by '\t'
location '/cars';
province string, --省份
month int, --月
city string, --市
county string, --区县
year int, --年
cartype string,--车辆型号
productor string,--制造商
brand string, --品牌
mold string,--车辆类型
owner string,--所有权
nature string, --使用性质
number int,--数量
ftype string,--发动机型号
outv int,--排量
power double, --功率
fuel string,--燃料种类
length int,--车长
width int,--车宽
height int,--车高
xlength int,--厢长
xwidth int,--厢宽
xheight int,--厢高
count int,--轴数
base int,--轴距
front int,--前轮距
norm string,--轮胎规格
tnumber int,--轮胎数
total int,--总质量
curb int,--整备质量
hcurb int,--核定载质量
passenger string,--核定载客
zhcurb int,--准牵引质量
business string,--底盘企业
dtype string,--底盘品牌
fmold string,--底盘型号
fbusiness string,--发动机企业
name string,--车辆名称
age int,--年龄
sex string --性别
)
row format delimited
fields terminated by '\t'
location '/cars';
使用以下命令为cars表导入数据,并查看导入是否成功:
hive> load data local inpath 'car.txt' into table cars;
Loading data to table car.cars
Table car.cars stats: [numFiles=0, totalSize=0]
OK
Time taken: 1.244 seconds
hive> select * from cars limit 2;
OK
山西省 3 朔州市
Loading data to table car.cars
Table car.cars stats: [numFiles=0, totalSize=0]
OK
Time taken: 1.244 seconds
hive> select * from cars limit 2;
OK
山西省 3 朔州市