• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
导航菜单
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • windows
  • 服务器硬件
  • 服务器运维
  • 云计算
  • 虚拟化
  • IIS教程
  • Linux
  • Apache
  • Ftp
  • DNS
  • Nginx
您的位置:首页 > 服务器 >云计算 > hive的变量传递设置,hive变量传递设置

hive的变量传递设置,hive变量传递设置

作者:网友 字体:[增加 减小] 来源:互联网

本文主要包含hive 变量,hive 设置默认值,hive 设置队列,hive设置reduce个数,hive游学网等服务器相关知识,网友希望可以进行参考

hive的变量传递设置,hive变量传递设置


hive的变量传递设置

今天同事在oozie的workflow中执行一个hive查询,但是直接就报异常:Variable substitution depth too large:40,从网上查询可知,可以确认是由于语句中使用了过多的变量导致,在hive以前的版本中,这个限制是写死的40个,查询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);
  }

如果开启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;
  } 

如果使用的${}参数超过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)

分享到:QQ空间新浪微博腾讯微博微信百度贴吧QQ好友复制网址打印

您可能想查找下面的文章:

  • hive的变量传递设置,hive变量传递设置

相关文章

  • @RequestMapping的params参数 @RequestMapping(params = &quot;method=save&quot;),requestmapping
  • spark core源码分析8 从简单例子看transformation,transformation
  • Hadoop之——自定义分组比较器实现分组功能,hadoop分组
  • Hadoop之——HBase笔记(补充),hadoophbase
  • Web.xml配置详解,web.xml详解
  • @PathVariable和@RequestParam的区别,@pathvariable
  • Spark编程指南V1.4.0(翻译),编程指南v1.4.0
  • Spark SQL and DataFrame Guide(1.4.1)——之DataFrames,sparkdataframe
  • Apriori算法的java实现,apriori算法java
  • HBase扫描器与过滤器,HBase扫描器过滤器

文章分类

  • windows
  • 服务器硬件
  • 服务器运维
  • 云计算
  • 虚拟化
  • IIS教程
  • Linux
  • Apache
  • Ftp
  • DNS
  • Nginx

最近更新的内容

    • IBM Symphony开发,ibmsymphony开发
    • 我与英语技术书籍,英语技术书籍
    • Spark性能优化:数据倾斜调优
    • 如何选择大数据培训机构,选择数据培训机构
    • Hadoop之——Partitioner编程,hadooppartitioner
    • 两款Docker管理UI:DockerUI &amp; Shipyard,dockerdockerui
    • Hadoop MapReduce编程的一些个人理解,hadoopmapreduce
    • hive FAILED: ParseException line 1:814 cannot recognize input near ‘;’ &lt;EOF&gt;’,hiveparseexception
    • Greenplum+Hadoop学习笔记-14-定义数据库对象之创建与管理序列、索引以及视图,hadoop-14-
    • hadoop权威指南(第四版)要点翻译(1)——Foreword and Preface,hadoopforeword

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有