在Python脚本中调用时,Hive尝试读取当前工作目录

时间:2017-11-24 13:22:41

标签: python hive subprocess

我正在尝试从Python包装器执行Hive脚本。部分代码看起来像

print(HiveArgs)
Hive = subprocess.Popen(HiveArgs, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
HiveOutput = Hive.communicate()

print("Out:" + HiveOutput[0])
print("=================================")
print("Err:" + HiveOutput[1])

这个输出是:

['hive', '-i ', '/edw/edwdev/tmp/spark.txn.init.tmp', '-f ', '/edw/edwdev/tmp/test.hql.tmp']
Out:
=================================
Err:
Logging initialized using configuration in file:/etc/hive/2.5.0.2-3/0/hive-log4j.properties
Exception in thread "main" java.io.FileNotFoundException: File file:/data/edw/edwdev/  does not exist
        at org.apache.hadoop.fs.RawLocalFileSystem.deprecatedGetFileStatus(RawLocalFileSystem.java:624)
        at org.apache.hadoop.fs.RawLocalFileSystem.getFileLinkStatusInternal(RawLocalFileSystem.java:850)
        at org.apache.hadoop.fs.RawLocalFileSystem.getFileStatus(RawLocalFileSystem.java:614)
        at org.apache.hadoop.fs.FilterFileSystem.getFileStatus(FilterFileSystem.java:422)
        at org.apache.hadoop.fs.ChecksumFileSystem$ChecksumFSInputChecker.<init>(ChecksumFileSystem.java:146)
        at org.apache.hadoop.fs.ChecksumFileSystem.open(ChecksumFileSystem.java:348)
        at org.apache.hadoop.fs.FileSystem.open(FileSystem.java:782)
        at org.apache.hadoop.hive.cli.CliDriver.processFile(CliDriver.java:427)
        at org.apache.hadoop.hive.cli.CliDriver.processInitFiles(CliDriver.java:439)
        at org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:708)
        at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:684)
        at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:624)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.apache.hadoop.util.RunJar.run(RunJar.java:233)
        at org.apache.hadoop.util.RunJar.main(RunJar.java:148)

其中/data/edw/edwdev/(Hive认为缺少的文件)是Linux服务器上的工作目录。

将工作目录更改为脚本的位置没有帮助。使用相对和绝对路径也没有区别。如果我从打印的HiveArgs复制值并从终端(hive -i /edw/edwdev/tmp/spark.txn.init.tmp -f /edw/edwdev/tmp/test.hql.tmp)执行命令,则它可以正常工作。

我在这里缺少什么?

0 个答案:

没有答案