hive中怎么设置变量传递
发表于:2025-02-01 作者:千家信息网编辑
千家信息网最后更新 2025年02月01日,hive中怎么设置变量传递,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。### org.apache.hadoop.hive.ql.pa
千家信息网最后更新 2025年02月01日hive中怎么设置变量传递
hive中怎么设置变量传递,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。
### org.apache.hadoop.hive.ql.parse.VariableSubstitution:
public String substitute(HiveConf conf, String expr) { if (expr == null) { return expr; } if (HiveConf.getBoolVar(conf, ConfVars.HIVEVARIABLESUBSTITUTE)) { l4j.debug("Substitution is on: " + expr); } else { return expr; } int depth = HiveConf.getIntVar(conf, ConfVars.HIVEVARIABLESUBSTITUTEDEPTH); return substitute(conf, expr, depth); }123456789101112
如果开启hive.variable.substitute(默认开启),则使用SystemVariables的substitute方法和hive.variable.substitute.depth(默认为40)进行进一步的判断:
protected final String substitute(Configuration conf, String expr, int depth) { Matcher match = varPat.matcher(""); String eval = expr; StringBuilder builder = new StringBuilder(); int s = 0; for (; s <= depth; s++) { match.reset(eval); builder.setLength(0); int prev = 0; boolean found = false; while (match.find(prev)) { String group = match.group(); String var = group.substring(2, group.length() - 1); // remove ${ .. } String substitute = getSubstitute(conf, var); if (substitute == null) { substitute = group; // append as-is } else { found = true; } builder.append(eval.substring(prev, match.start())).append(substitute); prev = match.end(); } if (!found) { return eval; } builder.append(eval.substring(prev)); eval = builder.toString(); } if (s > depth) { throw new IllegalStateException( "Variable substitution depth is deeper than " + depth + " for expression " + expr); } return eval; } 12345678910111213141516171819202122232425262728293031323334
如果使用的${}参数超过hive.variable.substitute.depth的数量,则直接抛出异常,所以我们在语句的前面直接加上set hive.variable.substitute.depth=100; 问题解决!
set命令的执行是在CommandProcessor实现类SetProcessor里具体执行,但是substitute语句同时也会在CompileProcessor中调用,也就是在hive语句编译时就调用了,所以oozie在使用时调用beeline执行语句时,compile阶段就报出异常。
但是为什么Hue直接执行这个语句时没有问题? 因为hue在执行hive时使用的是python开发的beeswax,而beeswax是自己直接处理了这些变量,使用变量实际的值替换变量后再提交给hive执行:
def substitute_variables(input_data, substitutions): """ Replaces variables with values from substitutions. """ def f(value): if not isinstance(value, basestring): return value new_value = Template(value).safe_substitute(substitutions) if new_value != value: LOG.debug("Substituted %s -> %s" % (repr(value), repr(new_value))) return new_value return recursive_walk(f, input_data)
看完上述内容,你们掌握hive中怎么设置变量传递的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注行业资讯频道,感谢各位的阅读!
变量
语句
问题
方法
内容
更多
束手无策
为此
也就是
原因
参数
同时
命令
实际
对此
技能
数量
时调
是在
篇文章
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
怀旧服服务器刷怪路线
网络安全流受到监控
鲲鹏服务器怎么进去raid界面
oracle服务器打补丁
浦发银行社招软件开发
ddr3 服务器内存频率
网络安全学习工作会议纪要
贾勇伟网络安全
旺旺软件开发
网络安全日 提倡
斗地主用什么软件开发
sqlite数据库迁移
服务器系统哪个比较安全
线上网络安全公开课心得
在数据库中的数据共享指的是什么
华为服务器的防火墙在哪里
数据库连接查询算法
云服务器4g带宽5m能用多少人
穿越火线哪个服务器最不卡
山东实用软件开发诚信推荐
成都神车网络技术官网
软件开发每年涨薪比例
腾讯云三大云服务器
赚钱软件开发商怎么赚钱
网络安全的src
三级网络技术用编程吗
合川网络安全产业城入驻条件
主服务器
药房网络安全应急措施
网络安全产业迎来黄金十年