shell脚本变量接收hive -e 返回值 “WARN:xxx...”

前言

直接上代码:

max_date=$(hive -e "select max(date) from table")
echo $max_date

本来就只是想去到日期的最大值20191121,可谁知道输出的结果却是:

20191121 WARN: The method class org.apache.commons.logging.impl.SLF4JLogFactory#release() was invoked. WARN: Please see http://www.slf4j.org/codes.html#relea
se for an explanation.

这样显然不能继续使用max_date变量了

这个Hive版本是1.1 CDH5.16.1默认的版本

如何解决

  • 过滤掉WARN日志
max_date=$(hive -e "select max(date) from table"  | grep -v "WARN")
echo $max_date

这种方法简单粗暴,也是我推荐的方式,毕竟不是所有的Hive版本都有这样的问题,这种方式不需要修改环境变量

  • 添加 export HIVE_SKIP_SPARK_ASSEMBLY=true; 到 /etc/profile
echo “export HIVE_SKIP_SPARK_ASSEMBLY=true;” >> /etc/profile
source /etc/profile

这种方式,我个人不推荐

发布了237 篇原创文章 · 获赞 140 · 访问量 17万+

猜你喜欢

转载自blog.csdn.net/Android_xue/article/details/103182437
今日推荐