记录下我实习时踩到的坑。我的记忆力比不上糟糕的写作,更何况我的记忆力太差了,不能做,离职后能带走的只有我自己的笔记经历和感受。
[En]
Record the pits I stepped on in my internship. My memory is not as good as bad writing, not to mention that my memory is too bad to do, and all I can take away after leaving my job is my own notes experience and feelings.
Hive SQL篇
- SQL执行顺序
- from:作from子句前两个表的笛卡尔积
- on:应用on筛选器,筛选出满足on逻辑表达式的行
- join:根据join的条件选择是上一步的行还是外部行
- where:应用where筛选器
- group by:开始分组
- having:对groupby 生成的虚拟表应用having条件
- select:想要的字段列
- distinct:删除掉重复的行
- order by:根据条件进行排序
- union 和 union all 的区别 :
- union 对两个结果集进行并集操作,不包括重复行;且对结果排序。
- union all 对两个结果集进行并集操作,包括重复行;不对结果排序。
- 去掉string中部分字符:
- substring( 字段名, 起始位置,截取长度)
注:截取长度可省略 - regexp_replace( 字段名, 被替换字符,替换字符)
- count一定要distinct否则计数无意义 (当然也可以group by啦)
关于两者性能之间的差别: - distinct 空间换时间,当数据集中时效率高,离散时效率低。
- group by 时间换空间,当数据集中时效率低,离散时效率高。
- 解析json字段:
get_json_object( 字段名,$表示json变量标识然后用 . 或 [] 读取对象或数组 )
第二个参数具体要看要解析的json的结构是什么样的,然后再拆。
我会用网上json解析(eg:菜鸟json在线解析)看清结构再拆。 - 跑数前检查分区
避免数还没产出就跑,区分清楚全量表和增量表 - date_sub() date_add()很好用
方便将限制日期和区域一起更改日期,第一个参数:日期,第二个参数:天数。[En]
Convenient to limit the date and the zone to change the date together, the first parameter: date, the second parameter: number of days.
- 窗口函数 很重要:
- 注意数据类型
注意检查数据类型,如string的数字排序会错误,需转换类型后排序 - 全量表和增量表
满刻度的最新部分存储了满量的历史数据,您可以选择最近的分区。[En]
The most recent section of the full scale stores a full amount of historical data, and you can choose the nearest partition.
增量表新分区存的是新增加的数据,比如取数需要取2月1号到3月1号的数据,那分区可以选择大于取数日期范围的数据,例如2.1到3.2,但具体范围大多少,要以具体需求进行考量。
- concat() 和 concat_ws()拼接函数
concat_ws 是 concat的 特殊形式 意为 CONCAT With Separator。
当参数中有null,concat则为null(不管其他参数是不是null)
concat_ws 会忽略null值,不会忽略其他参数。
concat_ws 中分割值可以为其他参数,concat不行,只能为str。
例如:concat(year,'-',month,'-',day)
concat_ws('-', year, month, day)年-月-日拼起来 - 用时间戳进行时区转化
from_unixtime(unix_timestamp(date) + timezone * 3600)
date实例: 2022-02-28 20:21:26
timezone实例:-11
乘以3600是为了转换成秒 - 分位数函数
percentile_approx(字段名, 想要看的分位数, 精度)
例如:percentile_approx(grade, array(0.05,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,0.95,0.97,0.99), 9999) - 日期转周数
weekofyear(date) as weekno - 有条件计数,求和
count(case when ...... then ...... end)
sum(case when ...... then ...... end) - Hive中设置变量
sql语句中直接用${var_name}调用 - 处理null值
nvl(字段名,替代值)
例子:nvl(number,0) - 建临时表
with 临时表名1 as( 建表逻辑 ),
临时表名2 as( 建表逻辑 ) - case when
case when 条件一 then 值一
when 条件二 then 值二 end as 新字段名 - 转换日期格式
to_date(time) - 表连接
以left join,join为主,搞清楚 - 当前日期时间
'$[YYYY-MM-DD]' 当前时间
'$[YYYY-MM-DD - 2D]' 当前时间减两天
'$[YYYY-MM-DD-HH - 48H]' 当前时间减48小时 - *建表调度结构
create table if not exists 表名(
字段名1 数据类型 COMMENT '备注'
name string COMMENT '姓名'
grade int COMMENT '成绩'
)
comment '整个表的备注'
partitioned by(
country string
, pt string -分区
);
set hive.exec.dynamic.partition.mode = nonstrict
insert overwrite table 表名 partition (country_code, pt)
select ............
from ............
where ............
- 时间取小时
hour(time) - 不等于
<> 或者 != - 保留几位小数
round(字段,小数点后几位) - 数据类型转换
cast(字段名 as 数据类型) - coalesce()
COALESCE是一个函数, (expression_1, expression_2, ...,expression_n)依次参考各参数表达式,遇到非null值即停止并返回该值。如果所有的表达式都是空值,最终将返回一个空值
eg: coalesce(name,0) - having语句
由于where不能使用聚合函数,当需要聚合函数限定的时候可以使用having语句
select......
from......
group by......
having sum(grade) > 600
* split()
split(字段,分隔符号)
* 行转列
select......
from......
lateral view explode(需展开的字段名)table名 as 新字段名
where......
- limit(起始,终止)
最后展示的行数
excel篇
- CSV文件改动会出错,下载完文件存为excel!!!不然改动完关闭文件,啥也不剩。
- iferror(value,value_if_error)
- vlookup(loopup_value, table_arry数据区域, col_index_num数据区域的第几列, 0精准查询 或 1模糊查询)
- sumifs(实际求和区域,第一个条件区域,第一个条件值,第二个条件区域,第二个条件值......)有时可以相当于多条件查询的vlookup
- 数据透视表要熟练运用
面经分享
面试岗位涉及数据分析师和数据工程师
- AB实验是什么以及流程叙述
- AB实验的分流(正交、互斥)
- AB实验如何分组,要注意什么
- 什么是辛普森悖论
- AB实验最小样本量计算公式
- 讲一讲你所做过的AB实验(STAR原则)
- 什么是AA实验,一般用于哪些场景
- 实际运用中你认为它有哪些弊端,需要注意哪些问题
- AB实验前需不需要假设
-
为什么AB实验要做假设检验
-
假设检验的流程
- P值的数学含义以及在AB实验中的含义)
- 如何给不懂技术的业务方解释P值
- 为什么我们倾向于将想要拒绝的假设设为原假设H0
- 一类错误二类错误是什么,在业务中是什么
- 一类错误二类错误哪个会造成更严重的影响
- α是什么
- 1-α是什么
- 检验方式分为什么(单侧双侧)有什么区别
- 拒绝域是什么
后续会继续更新
Original: https://blog.csdn.net/weixin_43168138/article/details/123092914
Author: Houly
Title: 数分实习踩坑笔记:Hive SQL
相关阅读
Title: Tensorflow 2.9.1安装笔记
CPU:i7-4790k
显卡:GTX2060
Cuda 版本:11.3
Cunn版本: 11.6
Python版本:3.7.7
不想用anacoda,直接装 tensorflow
1.准备工作
- 安装python3.7.7(之前安装好的)
可以根据需要安装相应的版本,不建议安装最新版,python版本之间的代码兼容度不好。3.6~3.8可能比较合适。
我安装的是11.3版本。
deviceQuery.exe 和 bandwithTest.exe测试通过。
- 下载Tensorflow
我下载的是 tensorflow-2.9.1-cp37-cp37m-win_amd64.whl
- 安装组件
安装Tensorflow之前,安装好以下支持模块
A.Numpy: pip install numpy -i https://pypi.tuna.tsinghua.edu.cn/simple
B.mkl: pip install mkl -i https://pypi.tuna.tsinghua.edu.cn/simple
C.protobuf pip install protobuf -i https://pypi.tuna.tsinghua.edu.cn/simple
2.安装Tensorflow
把 tensorflow-2.9.1-cp37-cp37m-win_amd64.whl 放到d盘根目录,打开命令行并转到D:\
pip install tensorflow-2.9.1-cp37-cp37m-win_amd64.whl -i https://pypi.tuna.tsinghua.edu.cn/simple
这样在安装过程中加载其他模块的时候,速度会非常快。
3.测试
import tensorflow as tf
print("Tensorflow version:")
print(tf.__version__)
print("CPU/GPU devices for Tensorflow:")
gpus = tf.config.experimental.list_physical_devices(device_type='GPU')
cpus = tf.config.experimental.list_physical_devices(device_type='CPU')
print(gpus)
print(cpus)
运行结果:
Tensorflow version:
2.9.1
CPU/GPU devices for Tensorflow:
[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]
[PhysicalDevice(name='/physical_device:CPU:0', device_type='CPU')]
至此安装完毕。
IDE可以使用Visual Studio Code(小规模测试)
或者Pycharm(程序较大很方便)
Original: https://blog.csdn.net/st01lsp/article/details/125294794
Author: st01lsp
Title: Tensorflow 2.9.1安装笔记

数据结构-(3)栈的操作

【论文学习】Multi-modal Knowledge Graphs for Recommender Systems

log4j配置输出到多个日志文件

数据报表体系搭建流程

英文文本处理流程

Picovoice离线语音识别在Linux系统的部署

数据挖掘背景知识1——大数据与机器学习之间的关系 初步了解数据挖掘 计算机视觉 语音识别 自然语言处理

空间音频 2

python3.7+anaconda3-5.3.1+pytorch1.10.1环境搭建

区域增长法和连通区域标记法【小记】

Python读取Excel表格

科大讯飞和百得思维_科大讯飞造假?真相来了

语音识别1-3语音克隆-语音转文字-聊天盒子-python

OpenCvSharp (C# OpenCV) DNN模块加载自己训练的TensorFlow模型做目标检测(含手势识别、骰子识别、菜品识别)(附源码)
