我正在尝试从.hql文件执行'copyToLocal',如下所示:

dfs -copyToLocal hdfs://nameservice1/HDFS_FOLDER1/HDFS_FOLDER2/file_name.dat /LOCAL_FOLDER1/LOCAL_FOLDER2/;

但是我得到下面提到的异常:
Error: Error while processing statement: null (state=,code=1)
    org.apache.hive.service.cli.HiveSQLException: Error while processing statement: null
            at org.apache.hive.jdbc.Utils.verifySuccess(Utils.java:239)
            at org.apache.hive.jdbc.Utils.verifySuccessWithInfo(Utils.java:225)
            at org.apache.hive.jdbc.HiveStatement.execute(HiveStatement.java:244)
            at org.apache.hive.beeline.Commands.executeInternal(Commands.java:902)
            at org.apache.hive.beeline.Commands.execute(Commands.java:1089)
            at org.apache.hive.beeline.Commands.sql(Commands.java:985)
            at org.apache.hive.beeline.BeeLine.dispatch(BeeLine.java:1085)
            at org.apache.hive.beeline.BeeLine.execute(BeeLine.java:917)
            at org.apache.hive.beeline.BeeLine.executeFile(BeeLine.java:895)
            at org.apache.hive.beeline.BeeLine.begin(BeeLine.java:837)
            at org.apache.hive.beeline.BeeLine.mainWithInputRedirection(BeeLine.java:482)
            at org.apache.hive.beeline.BeeLine.main(BeeLine.java:465)
            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:221)
            at org.apache.hadoop.util.RunJar.main(RunJar.java:136)
    Caused by: org.apache.hive.service.cli.HiveSQLException: Error while processing statement: null
            at org.apache.hive.service.cli.operation.Operation.toSQLException(Operation.java:385)
            at org.apache.hive.service.cli.operation.HiveCommandOperation.runInternal(HiveCommandOperation.java:116)
            at org.apache.hive.service.cli.operation.Operation.run(Operation.java:327)
            at org.apache.hive.service.cli.session.HiveSessionImpl.executeStatementInternal(HiveSessionImpl.java:424)
            at org.apache.hive.service.cli.session.HiveSessionImpl.executeStatementAsync(HiveSessionImpl.java:401)
            at sun.reflect.GeneratedMethodAccessor18.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.lang.reflect.Method.invoke(Method.java:498)
            at org.apache.hive.service.cli.session.HiveSessionProxy.invoke(HiveSessionProxy.java:78)
            at org.apache.hive.service.cli.session.HiveSessionProxy.access$000(HiveSessionProxy.java:36)
            at org.apache.hive.service.cli.session.HiveSessionProxy$1.run(HiveSessionProxy.java:63)
            at java.security.AccessController.doPrivileged(Native Method)
            at javax.security.auth.Subject.doAs(Subject.java:422)
            at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1709)
            at org.apache.hive.service.cli.session.HiveSessionProxy.invoke(HiveSessionProxy.java:59)
            at com.sun.proxy.$Proxy21.executeStatementAsync(Unknown Source)
            at org.apache.hive.service.cli.CLIService.executeStatementAsync(CLIService.java:258)
            at org.apache.hive.service.cli.thrift.ThriftCLIService.ExecuteStatement(ThriftCLIService.java:500)
            at org.apache.hive.service.cli.thrift.TCLIService$Processor$ExecuteStatement.getResult(TCLIService.java:1313)
            at org.apache.hive.service.cli.thrift.TCLIService$Processor$ExecuteStatement.getResult(TCLIService.java:1298)
            at org.apache.thrift.ProcessFunction.process(ProcessFunction.java:39)
            at org.apache.thrift.TBaseProcessor.process(TBaseProcessor.java:39)
            at org.apache.hadoop.hive.thrift.HadoopThriftAuthBridge$Server$TUGIAssumingProcessor.process(HadoopThriftAuthBridge.java:746)
            at org.apache.thrift.server.TThreadPoolServer$WorkerProcess.run(TThreadPoolServer.java:286)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
            at java.lang.Thread.run(Thread.java:745)

但是,当我在一段时间后使用相同的.hql文件执行相同的语句时,它会按预期复制到本地。 谁能帮助我了解为什么会这样吗?
Version: Hive 1.1.0-cdh5.8.3

更新1 :我使用“get”而不是“copyToLocal”,并且得到了相同的异常。

更新2 :此文件具有粘性位:
-rwxrwxrwt .....  /HDFS_FOLDER1/HDFS_FOLDER2/file_name.dat

我是创建文件的用户,我正在尝试使用HQL文件中的dfs选项将其从HDFS复制到本地文件夹。

最佳答案

HADOOP命令用于复制到本地文件位置。

hdfs dfs -copyToLocal <input> <output>

这是您的确切示例:
hdfs dfs -copyToLocal /nameservice1/HDFS_FOLDER1/HDFS_FOLDER2/file_name.dat /LOCAL_FOLDER1/LOCAL_FOLDER2;

这是不推荐使用的版本:
hadoop fs -copyToLocal /nameservice1/HDFS_FOLDER1/HDFS_FOLDER2/file_name.dat /LOCAL_FOLDER1/LOCAL_FOLDER2;

HIVE命令,用于将文件复制到本地文件位置。
 INSERT OVERWRITE LOCAL DIRECTORY '/your/directory/in/local' SELECT * FROM myTable

关于hadoop - hive :dfs copyToLocal给出 “org.apache.hive.service.cli.HiveSQLException: Error while processing statement: null”,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/41224222/

10-12 04:59