应该有人在使用 hive 的时候 不小心创建了一些 特殊分区 , 分区的编码 是看起来的乱码, 我们现在来看看这个问题
create table test.test_part
(
a string,
b string,
c int
) comment '测试不正常分区'
partitioned by ( d string)
STORED AS ORC;
原先有一个已经有数据的表
insert into test.test_part partition(d='bb')
select
name10,
id2,
age
from test.buf_bdptest_diy limit 100
本来执行
hive -hiveconf day_s='2019-07-03' -f 文件名.sql
插入带变量的, 但是没有传入参数
insert into test.test_part partition(d='${hiveconf:day_s}')
select
name10,
id2,
age
from test.buf_bdptest_diy limit 100
查看分区
show partitions test.test_part;
直接带引号 '$%7Bhiveconf%3Aday_s}' 删除这个分区是无法删除的
需要把含有特殊字符串的使用 双引号包含
alter table test.test_part drop partition (d="${hiveconf:day_s}");
show partitions test.test_part;
已经不存在那个分区了,
问题 原因 : 需要 使用 双引号 "" 把你的特殊字符给引用起来 , 使用双引号的时候不会吧对应的参数给进行 16进制编码, 这样就不会出现这个问题
如果找不到 怎么去解析这个字符 可以找一个 url 解析网站解析一下就行
例如
https://www.bejson.com/enc/urlencode/