先自我介绍一下,小编浙江大学毕业,去过华为、字节跳动等大厂,目前阿里P7
深知大多数程序员,想要提升技能,往往是自己摸索成长,但自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年最新大数据全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友。
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上大数据知识点,真正体系化!
由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新
如果你需要这些资料,可以添加V获取:vip204888 (备注大数据)
正文
defense_max int comment '最大物防',
attack_range string comment '攻击范围',
role_main string comment '主要定位',
role_assist string comment '次要定位'
) comment ‘射手表’ row format delimited fields terminated by ‘\t’;
2.2上传(6个)源文件到该hive表的HDFS路径下
![](https://img-blog.csdnimg.cn/direct/c0eb55c8031846318238ae7d094d863f.png)
##### 3.查询数据
select * from t_all_hero;
![](https://img-blog.csdnimg.cn/direct/9211abf933aa4a01881d8b1708b554e6.png)
3.1查询出所有的archer数据
select * from t_all_hero where role_main=‘archer’;
问:虽然我们实现了需求, 但是需要进行全表扫描, 如何精准的获取到我们想要的数据呢?
答:可以采用分区表的思路来管理, 把各个职业的数据放到不同的文件夹中即可
##### 4.创建分区数据表
– 1. 创建分区表, 指定分区字段. create table t_all_hero_part( id int comment ‘ID’, name string comment ‘英雄’, hp_max int comment ‘最大生命’, mp_max int comment ‘最大法力’, attack_max int comment ‘最高物攻’, defense_max int comment ‘最大物防’, attack_range string comment ‘攻击范围’, role_main string comment ‘主要定位’, role_assist string comment ‘次要定位’ ) comment ‘角色表’ partitioned by (role string comment ‘角色字段-充当分区字段’) – 核心细节: 分区字段必须是表中没有的字段. row format delimited fields terminated by ‘\t’;
注意:分区字段必须是新的字段,表中没有的字段哦
##### 5.添加数据
###### 5.1添加方式1:静态分区(需要指定分区字段和值)
load data local inpath ‘/export/hivedata/archer.txt’ into table t_all_hero_part partition(role=‘sheshou’); load data local inpath ‘/export/hivedata/assassin.txt’ into table t_all_hero_part partition(role=‘cike’); load data local inpath ‘/export/hivedata/mage.txt’ into table t_all_hero_part partition(role=‘fashi’); load data local inpath ‘/export/hivedata/support.txt’ into table t_all_hero_part partition(role=‘fuzhu’); load data local inpath ‘/export/hivedata/tank.txt’ into table t_all_hero_part partition(role=‘tanke’); load data local inpath ‘/export/hivedata/warrior.txt’ into table t_all_hero_part partition(role=‘zhanshi’);
5.1.1此时HDFS中已已经根据我们的要求分好区
![](https://img-blog.csdnimg.cn/direct/9f4785fbffe24fa88660fc2bfe92d990.png)
5.1.2我们再次查询archer所有的数据时就可以根据分区字段进行筛选,避免全表扫描,提高查询效率.
select * from t_all_hero_part where role=‘sheshou’;
###### 5.2添加方式2:动态分区(只需指定分区字段,分区字段相同的数据自动分配到同一个区)
在进行动态分区前建议: 手动关闭严格模式
set hive.exec.dynamic.partition.mode=nonstrict;
5.2.1创建分区表
– 1. 创建分区表. create table t_all_hero_part_dynamic( id int comment ‘ID’, name string comment ‘英雄’, hp_max int comment ‘最大生命’, mp_max int comment ‘最大法力’, attack_max int comment ‘最高物攻’, defense_max int comment ‘最大物防’, attack_range string comment ‘攻击范围’, role_main string comment ‘主要定位’, role_assist string comment ‘次要定位’ ) comment ‘角色表’ partitioned by (role string comment ‘角色字段-充当分区字段’) – 核心细节: 分区字段必须是表中没有的字段. row format delimited fields terminated by ‘\t’;
5.2.2动态分区方式添加数据
由于建表时增加一个role的分区字段,所以总共有9个普通字段和1个分区字段,所以插入数据时select语句中需要单独加上一个分区字段
– 2. 动态分区的方式, 添加数据. insert into table t_all_hero_part_dynamic partition(role) select *, role_main from t_all_hero; – role main字段做为分区字段使用
5.2.3查询分区表所有数据
– 3. 查询分区表的数据. select * from t_all_hero_part_dynamic;
5.2.4查询分区表中archer所有数据
select * from t_all_hero_part_dynamic where role=‘archer’;
![](https://img-blog.csdnimg.cn/direct/711d1797c72c4325a299087e973027d6.png)
#### 三、多级分区表
*我们已经了解了单级分区但实际开发中在数据量比较大的情况下大多数采用多级分区来存储数据, 多级分区一般用采用时间来分区, 可以是: 年, 月, 日...。分区层级不建议超过3级, 一般是: 年, 月2级就够了。*
##### 1.准备工作
– 创建数据库 create database if not exists products; – 切库 use products;
##### 2.创建分区表(按照年、月分区)
– 1. 创建商品表, 按照: 年, 月分区. create table products( pid int, pname string, price int, cid string ) comment ‘商品表’ partitioned by (year int, month int) – 按照年, 月分区, 2级分区 row format delimited fields terminated by ‘,’;
##### 3.查询数据
3.1查找2023年1月分区下的所有数据
– 查找2023年1月分区下的所有数据 select * from products where year=2023 and month=1;
3.1.2HDFS中已经按要求分为2023年和2024年两个区,并且也分了二级月分区
![](https://img-blog.csdnimg.cn/direct/96a0e67946044846a33eb74e5f824681.png)![](https://img-blog.csdnimg.cn/direct/2e54e64c2353422cb79d4bf009a92e76.png)
##### 4.修改分区
**网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。**
**需要这份系统化的资料的朋友,可以添加V获取:vip204888 (备注大数据)**
![img](https://img-blog.csdnimg.cn/img_convert/f67d5f2a7fe391337de9f63265f90e6b.png)
**一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!**
**网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。**
**需要这份系统化的资料的朋友,可以添加V获取:vip204888 (备注大数据)**
[外链图片转存中...(img-3bog3HTn-1713297737222)]
**一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!**
相关文章
发表评论