hive storagehandler引发异常“配置和输入路径不一致”

wgeznvg7  于 2021-06-03  发布在  Hadoop
关注(0)|答案(1)|浏览(266)

我有一个 HiveStorageHandler 如果我这样做了 select * from myTable 它返回底层存储中的所有行。
当我做类似的事情 select col1 from myTable 基础mapreduce作业引发异常:

java.lang.RuntimeException: Error in configuring object
    at org.apache.hadoop.util.ReflectionUtils.setJobConf(ReflectionUtils.java:109)
    at org.apache.hadoop.util.ReflectionUtils.setConf(ReflectionUtils.java:75)
    at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:133)
    at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:413)
    at org.apache.hadoop.mapred.MapTask.run(MapTask.java:332)
    at org.apache.hadoop.mapred.Child$4.run(Child.java:268)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:415)
    at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1438)
    at org.apache.hadoop.mapred.Child.main(Child.java:262)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.hadoop.util.ReflectionUtils.setJobConf(ReflectionUtils.java:106)
    ... 9 more
Caused by: java.lang.RuntimeException: Error in configuring object
    at org.apache.hadoop.util.ReflectionUtils.setJobConf(ReflectionUtils.java:109)
    at org.apache.hadoop.util.ReflectionUtils.setConf(ReflectionUtils.java:75)
    at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:133)
    at org.apache.hadoop.mapred.MapRunner.configure(MapRunner.java:34)
    ... 14 more
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.hadoop.util.ReflectionUtils.setJobConf(ReflectionUtils.java:106)
    ... 17 more
Caused by: java.lang.RuntimeException: Map operator initialization failed
    at org.apache.hadoop.hive.ql.exec.ExecMapper.configure(ExecMapper.java:119)
    ... 22 more
Caused by: org.apache.hadoop.hive.ql.metadata.HiveException: org.apache.hadoop.hive.ql.metadata.HiveException: Configuration and input path are inconsistent
    at org.apache.hadoop.hive.ql.exec.MapOperator.setChildren(MapOperator.java:526)
    at org.apache.hadoop.hive.ql.exec.ExecMapper.configure(ExecMapper.java:90)
    ... 22 more
Caused by: org.apache.hadoop.hive.ql.metadata.HiveException: Configuration and input path are inconsistent
    at org.apache.hadoop.hive.ql.exec.MapOperator.setChildren(MapOperator.java:520)
    ... 23 more
2015-02-12 15:45:51,881 INFO org.apache.hadoop.mapred.Task: Runnning cleanup for the task

如果我介绍一个 HiveMetaHook.preCreateTable 将位置设置为我在hdfs上的输入路径,然后它就可以工作了。但是我的路径是动态变化的,我无法不断更新此属性:

@Override
    public void preCreateTable(Table tbl) throws MetaException {
        if (tbl.getSd().getLocation() != null) {
            throw new MetaException("LOCATION should be null.");
        }

         tbl.getSd().setLocation(*hard-coded-input-path*);
    }

我是根据下面的帖子做的。

suzh9iv8

suzh9iv81#

这是因为我在改变 mapred.input.dir 动态指向hdfs上的特定文件。现在,一旦我完成了自己的计算,我设置了 mapred.input.dir 回到Hive设定的状态。
我有我自己的 Split 为了这个 InputFormat . 所以每次 FileSplit.getPath() 调用时,我返回hive所期望的原始值 mapred.input.dir 现在一切正常了。

class MySplit extends org.apache.hadoop.mapred.FileSplit {

public MySplit(InputSplit actualSplit, String hiveInputPath) {
  super (new Path(hiveInputPath), 0,0, (String[]) null);
  this.actualSplit = actualSplit;
}

//do not override getPath that way hiveInputPath is returned

InputSplit getActualSplit() {
  return actualSplit;
}

....
}

相关问题