<?xml version="1.0" encoding="utf-8" ?><rss version="2.0"><channel><title><![CDATA[abc5254065的博客]]></title><description><![CDATA[]]></description><link>https://blog.youkuaiyun.com/abc5254065</link><language>zh-cn</language><generator>https://blog.youkuaiyun.com/</generator><copyright><![CDATA[Copyright &copy; abc5254065]]></copyright><item><title><![CDATA[SparkSQL相关知识点和使用示例]]></title><link>https://blog.youkuaiyun.com/abc5254065/article/details/131999268</link><guid>https://blog.youkuaiyun.com/abc5254065/article/details/131999268</guid><author>abc5254065</author><pubDate>Sun, 30 Jul 2023 11:46:26 +0800</pubDate><description><![CDATA[其中从Spark2.0开始:DataFrame 每一行的类型固定为RowDataset 每一行的类型都是一个case class。]]></description><category></category></item><item><title><![CDATA[Hive相关参数设置]]></title><link>https://blog.youkuaiyun.com/abc5254065/article/details/130373662</link><guid>https://blog.youkuaiyun.com/abc5254065/article/details/130373662</guid><author>abc5254065</author><pubDate>Tue, 25 Apr 2023 20:52:05 +0800</pubDate><description><![CDATA[【代码】Hive相关参数设置。]]></description><category></category></item><item><title><![CDATA[程序开发规范例子]]></title><link>https://blog.youkuaiyun.com/abc5254065/article/details/130171915</link><guid>https://blog.youkuaiyun.com/abc5254065/article/details/130171915</guid><author>abc5254065</author><pubDate>Sat, 15 Apr 2023 16:43:04 +0800</pubDate><description><![CDATA[【代码】程序开发规范例子。]]></description><category></category></item><item><title><![CDATA[hive中处理数据倾斜]]></title><link>https://blog.youkuaiyun.com/abc5254065/article/details/124740755</link><guid>https://blog.youkuaiyun.com/abc5254065/article/details/124740755</guid><author>abc5254065</author><pubDate>Thu, 12 May 2022 22:12:13 +0800</pubDate><description><![CDATA[1.count(distinct)
当某key的值过多时，处理此key的reduce非常耗时，因为只有一个reduce任务
解决办法：将值为空的情况单独处理，如过滤空值的行，在最后结果中加1
2.不同类型关联产生数据倾斜
如int类型和string类型做join操作时，reduce非常耗时，只有一个reduce
解决办法:把int类型转换成string类型
3.开启数据倾斜负载均衡
set hive.groupby.skewindata=true

处理过程：生成两个MRJob,先随机分发处理，再通过key]]></description><category></category></item><item><title><![CDATA[SQL优化]]></title><link>https://blog.youkuaiyun.com/abc5254065/article/details/124739809</link><guid>https://blog.youkuaiyun.com/abc5254065/article/details/124739809</guid><author>abc5254065</author><pubDate>Thu, 12 May 2022 21:33:37 +0800</pubDate><description><![CDATA[1.参数是子查询时，使用EXISTS代替IN
有子查询时exists的速度更快一些，如下:


以上两张表数据量都为百万级，sid字段为索引字段，使用not in耗时1分44秒，而使用not exists只耗时15秒，时间差异显著
当连接列上建了索引，使用exists只需要查索引，不需要扫描整张表
2.避免排序
会进行排序的子句

group by
order by
聚合函数（sum,count,avg,max,min）
distinct
集合运算符（union,ntersect,except）

2.1 ]]></description><category></category></item><item><title><![CDATA[SQL执行报错实例及原因解析]]></title><link>https://blog.youkuaiyun.com/abc5254065/article/details/124460196</link><guid>https://blog.youkuaiyun.com/abc5254065/article/details/124460196</guid><author>abc5254065</author><pubDate>Wed, 27 Apr 2022 20:46:22 +0800</pubDate><description><![CDATA[mysql执行sql:


update t1 set a=(select b-c from t1);

报错：“ERROR 1093 (HY000) at line 15:You can’t specify target table ‘t1’ for update in from clause”
报错原因:对于同一个表的select和update不能出现在同一语句中
修改sql:
update t1 set a=(select b-c from (select b,c from t1 ) tmp);
..]]></description><category></category></item><item><title><![CDATA[Mysql常用函数介绍]]></title><link>https://blog.youkuaiyun.com/abc5254065/article/details/122718995</link><guid>https://blog.youkuaiyun.com/abc5254065/article/details/122718995</guid><author>abc5254065</author><pubDate>Thu, 27 Jan 2022 15:52:08 +0800</pubDate><description><![CDATA[1.字符字节长度
--获取字节长度  length   获取字符长度  char_length
length("张三")   4
char_length("张三")  2
length("zs")    2
char_length("zs")  2

2.字段字符截取函数
--截取center字段中索引从1到','前一个位置的字符,若','位置为19，则截取1-18
select substr(center,1,instr(center,',')-1) from test;
--截取center字段中索引从]]></description><category></category></item><item><title><![CDATA[实用的SQL语句]]></title><link>https://blog.youkuaiyun.com/abc5254065/article/details/122717553</link><guid>https://blog.youkuaiyun.com/abc5254065/article/details/122717553</guid><author>abc5254065</author><pubDate>Thu, 27 Jan 2022 14:46:17 +0800</pubDate><description><![CDATA[1.如果t1表id字段等于t2表id字段，则令t1表的center字段等于t2表的center字段
update t1  set center=(select center from t2  where t1.id=t2.id )
where t1.id in (select id from t2);

2.删除表中有问题的记录：
本来正确记录的字段值应该是1,2;33,22;11,222;可是有些记录的字段值却是1,2;5;33,22; 要把有;5;的记录删除了
(1) 先查出有问题的记录
--正常来讲,]]></description><category></category></item><item><title><![CDATA[实用的shell脚本例子]]></title><link>https://blog.youkuaiyun.com/abc5254065/article/details/122702254</link><guid>https://blog.youkuaiyun.com/abc5254065/article/details/122702254</guid><author>abc5254065</author><pubDate>Wed, 26 Jan 2022 15:00:06 +0800</pubDate><description><![CDATA[#实用的shell脚本
##1.按月导出mysql日表中的数据，导出后再删除天表
#!/bin/bash
month1=`date '+%Y%m' -d '-1 months'`
monthfirst=`date '+%Y%m01'`
month1last=`date -d "$monthfirst last day" +%d`
i=1
j=1
##导出数据文件存放路径
outdir=/data/mysql_export
#遍历有日期后缀的表
while [ $i -le $month1last ];do
]]></description><category></category></item><item><title><![CDATA[shell知识点总结]]></title><link>https://blog.youkuaiyun.com/abc5254065/article/details/122563696</link><guid>https://blog.youkuaiyun.com/abc5254065/article/details/122563696</guid><author>abc5254065</author><pubDate>Tue, 18 Jan 2022 17:02:07 +0800</pubDate><description><![CDATA[标准输入：控制台输入内容到变量name


#!/bin/bash
read name
echo $name

if 条件判断：

如果$1 字符串长度为0即为空，则date=`date '+%Y%m%d'`,否则为date=$1


if [ -z $1 ]
then
date=`date '+%Y%m%d'`
else
date=$1
fi

如果文件存在且大小不为0为真if [ -s 文件名 ]
如果文件存在if [ -e 文件名 ]
如果两个字符串相同则为真
if [string1 =stri...]]></description><category></category></item><item><title><![CDATA[linux 命令整理]]></title><link>https://blog.youkuaiyun.com/abc5254065/article/details/122563284</link><guid>https://blog.youkuaiyun.com/abc5254065/article/details/122563284</guid><author>abc5254065</author><pubDate>Tue, 18 Jan 2022 16:49:43 +0800</pubDate><description><![CDATA[1.grep用法

搜索该文件夹下的文件内容grep -irl 关键字

列出a.txt中所有的逗号,每个逗号一行grep -o ',' a.txt
算出a.txt中逗号的个数grep -o ',' a.txt | wc -w

查看文件中是否有.sh 忽略大小写cat a.txt | grep -i .sh
查看文件中出现1808的行grep 1808 a.txt

2.du命令

查看当前文件夹下内容占用存储总大小，自动变更为kb mb Gbdu -sh
查看当前文件夹下每个文件(或者文件夹)占....]]></description><category></category></item><item><title><![CDATA[mysql存储过程相关]]></title><link>https://blog.youkuaiyun.com/abc5254065/article/details/122563176</link><guid>https://blog.youkuaiyun.com/abc5254065/article/details/122563176</guid><author>abc5254065</author><pubDate>Tue, 18 Jan 2022 16:39:38 +0800</pubDate><description><![CDATA[查看所有的存储过程

show procedure status where Db='databasename';

查看存储过程的创建过程

show create procedure 存储过程名;

案例1

如果最大日期和第二大日期不等，则更新表字段:


drop procedure p_name;
delimiter $$
create procedure p_name()
begin
declare first_dt varchar(32);
declare sencond_dt varchar]]></description><category></category></item><item><title><![CDATA[Hive常用函数介绍]]></title><link>https://blog.youkuaiyun.com/abc5254065/article/details/122394795</link><guid>https://blog.youkuaiyun.com/abc5254065/article/details/122394795</guid><author>abc5254065</author><pubDate>Tue, 18 Jan 2022 16:35:49 +0800</pubDate><description><![CDATA[1.instr

搜索字符串中指定字符出现的位置，如果没有找到则返回0

instr("abcd",'b')

结果2

2.substr

substr("abcdef",1,3) ab

substr("abcdef",4)

字符串截取函数，截取指定字符串的内容,若字符串后的参数个数为2，则截取1-3位置(初始位置为0)的字符串;

若
...]]></description><category></category></item><item><title><![CDATA[易鲸捷数据库（EsgynDB）常用SQL]]></title><link>https://blog.youkuaiyun.com/abc5254065/article/details/122394510</link><guid>https://blog.youkuaiyun.com/abc5254065/article/details/122394510</guid><author>abc5254065</author><pubDate>Sun, 09 Jan 2022 15:54:42 +0800</pubDate><description><![CDATA[1.数据库连接


trafci.sh -h 主机ip -u 用户名 -p 密码 &lt;&lt;EOF
cqd attempt_esp_parallelism 'on';
set schema 库名;

--SQL

cqd attempt_esp_parallelism 'off';
exit;
EOF

2.表创建和截断


create table if not exists 库名.t1(
id varchar(32),
name varchar(32)
)

truncate table 库名.t]]></description><category></category></item><item><title><![CDATA[Hive使用中经常用到的SQL]]></title><link>https://blog.youkuaiyun.com/abc5254065/article/details/122393770</link><guid>https://blog.youkuaiyun.com/abc5254065/article/details/122393770</guid><author>abc5254065</author><pubDate>Sun, 09 Jan 2022 15:25:17 +0800</pubDate><description><![CDATA[1.表创建

1.1方式1


create table  t1(
org_id int,
banner string,
pv int,
uv int)
partitioned by(day_id string) ##分区
row format delimited fields terminated  by '\t'
stored as textfile;

1.2方式2


create table  t2 as select * from t1;

1.3方式3


create table t2 li]]></description><category></category></item><item><title><![CDATA[HDFS常用命令]]></title><link>https://blog.youkuaiyun.com/abc5254065/article/details/122393578</link><guid>https://blog.youkuaiyun.com/abc5254065/article/details/122393578</guid><author>abc5254065</author><pubDate>Sun, 09 Jan 2022 14:46:27 +0800</pubDate><description><![CDATA[1.删除文件

hdfs dfs -rm filename

2.删除文件夹

hdfs dfs -rm -r filedir

3.创建文件夹

hdfs dfs -mkdir

4.递归创建文件夹/文件

hdfs dfs -mkdir -p

5.查看目录下文件夹大小

hdfs dfs -du -h /bonc_dg/

6.查看目录资源使用率

hdfs dfs -df -h /bonc_dg/

7.查看hadoop版本命令

hadoop version

8.查看正在运行的hive进程

h]]></description><category></category></item><item><title><![CDATA[Mysql使用过程中经常用到的SQL]]></title><link>https://blog.youkuaiyun.com/abc5254065/article/details/120787773</link><guid>https://blog.youkuaiyun.com/abc5254065/article/details/120787773</guid><author>abc5254065</author><pubDate>Fri, 15 Oct 2021 17:58:20 +0800</pubDate><description><![CDATA[1.创建表

1.1普通表


create table if not exists center_point_tmp_fqw(
id int(11) comment '全局唯一id',
org_id varchar(20) default null comment '组织id',
center_point mediumblob comment '中心点',
primary key (id)
) engine=innodb default charset=utf8;

1.2主键字段自增表


create]]></description><category></category></item><item><title><![CDATA[MapReduce中Shuffle的机制]]></title><link>https://blog.youkuaiyun.com/abc5254065/article/details/113006226</link><guid>https://blog.youkuaiyun.com/abc5254065/article/details/113006226</guid><author>abc5254065</author><pubDate>Fri, 22 Jan 2021 22:40:11 +0800</pubDate><description><![CDATA[Shuffle过程指的是MapTask的map方法之后，ReduceTask的reduce方法之前的数据处理过程，Shuffle过程是MR中最关键的一个流程；

Shuffle过程包括Collect阶段，Spill阶段，两次Merge阶段，Copy阶段，Merge阶段以及Sort阶段，每阶段过程如下：


...]]></description><category></category></item><item><title><![CDATA[HiveSQL语句中SELECT,FROM,WHERE,GROUP BY,LIMIT,ORDER BY的执行顺序]]></title><link>https://blog.youkuaiyun.com/abc5254065/article/details/113006149</link><guid>https://blog.youkuaiyun.com/abc5254065/article/details/113006149</guid><author>abc5254065</author><pubDate>Fri, 22 Jan 2021 22:31:04 +0800</pubDate><description><![CDATA[1.from

2.where

3.group by

4.order by

5.limit

6.select
]]></description><category></category></item><item><title><![CDATA[Hive中sort by ,order by ,cluster by ,distribute by各代表什么意思]]></title><link>https://blog.youkuaiyun.com/abc5254065/article/details/112983989</link><guid>https://blog.youkuaiyun.com/abc5254065/article/details/112983989</guid><author>abc5254065</author><pubDate>Fri, 22 Jan 2021 14:26:49 +0800</pubDate><description><![CDATA[sort by 会在每个reduce中排序，全局无序，但是分区内有序
	order by 对输入做全局排序，只有一个reduce,当输入规模较大时，消耗时间很大
	distribute by 根据字段进行分区，类似MR中Partition,进行分区，结合sort by 使用
	cluster by等价于distribute by sort by，排序只能是升序排序，无法指定排序规则
...]]></description><category></category></item></channel></rss>