其他分享
首页 > 其他分享> > HIVE:

HIVE:

作者:互联网

my_cluster.sh start
(1-标准输出,2-错误输出,2>&1 : 表示将错误重定向到标准输出上,&: 放在命令结尾,表示后台运行)
nohup hive --service metastore 1>/opt/module/hive-3.1.2/logs/metastore.log 2>&1 &
nohup hive --service hiveserver2 1>/opt/module/hive-3.1.2/logs/hiveSercer2.log 2>&1 &
beeline -u jdbc:hive2://hadoop102:10000 -n atguigu ---退出命令 ----> !quit

停止所有的RunJar进程
jps | grep RunJar | awk '{print $1}' | xargs -n1 kill -9

hive启停脚本
-- hiveService.sh start
-- 等一会,再启动
-- beeline -u jdbc:hive2://hadoop102:10000 -n atguigu
-- hiveService.sh stop

将JSON格式转为以下形式,存在coll.txt文件中;
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 collection(
name string ,
friends array<string>,
childrens map<string,int>,
address struct<street:string,city:string>
)
row format delimited fields terminated by ','
collection items terminated by '_'
map keys terminated by ':'
lines terminated by '\n';

数据存在coll.txt文件中
load data local inpath '/opt/module/hive-3.1.2/datas/coll.txt' into table collection;
加载数据 本地路径(存放的数据) 目标表

查询另一种方式:
struct-->address struct<street:string,city:string> ---> 查询时可以将strut的集合属性类比于java的对象
select name,friends[0],childrens['xiao song'],address.street from collection;

标签:terminated,struct,--,hive,coll,HIVE,collection
来源: https://www.cnblogs.com/kiku-58546494/p/16022562.html