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;

posted on   はやのうた  阅读(163)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 字符编码:从基础到乱码解决
· 提示词工程——AI应用必不可少的技术
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

点击右上角即可分享
微信分享提示