1、外部表删除方法
需要确认 external.table.purge 属性
alter table db_name.table_1 set tblproperties('external.table.purge'='true');
drop table db_name.table_1;
2、修复表
表数据文件跨库复制后,修复表
hdfs dfs -cp /old_path/* /new_path
msck repair table db_name.table_2;
3、分区字段值显示为特殊符号
显示为url编码了,含义如下
%2F 代表 /
%7B 代表 {
%3A 代表 :
删除分区
alter table db_name.table_3 drop partition (etl_date='${hivevar:rundate}');
4、hivesql正则报错
设置参数
set hive.support.quoted.identifiers = none;
示例1:过滤掉不需要的列名(字段要用小括号包裹)
select `(id|name)?+.+` from user_info;
示例2:模糊匹配有相似性的列名
select `.+score` from user_info;
5、hive空指针异常
hive NullPointerException
原因分析:多表关联,创建新表,关联的两个表有相同字段名的字段,hive为了区分就带上了表名前缀,导致建表字段不合法。select 查询时,识别不了字段名,抛出空指针异常。
其他可能出现此错误的原因:
1. 分区表未指定分区
2. Union all情况下,前后2段的字段名、数据类型不匹配;验证结果是:会提示类型不匹配,不会报空指针异常。
insert overwrite table table_name select '2019-04-12' min_date,'2019-04-12' conf_date;
在hivesql里这样写,可能会报空指针错误。验证结果是:不会报错,能正常执行。
6、数组下标越界
ArrayIndexOutOfBoundsException
解决方法:重跑分区数据
7、is not a Parquet file
查看表的存储格式,同时查看hdfs上数据文件的是什么格式?
8、Error reading file
解决方法:重跑分区数据
待完善补充