title: Hive: dfs copyToLocal gives "org.apache.hive.service.cli.HiveSQLException: Error while processing statement: null"
body: <p>I am trying to do a 'copyToLocal' from a .hql file, like this:</p>
  
  <pre><code>dfs -copyToLocal hdfs://nameservice1/HDFS_FOLDER1/HDFS_FOLDER2/file_name.dat /LOCAL_FOLDER1/LOCAL_FOLDER2/;
  </code></pre>
  
  <p>But I get this below mentioned exception:</p>
  
  <pre><code>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)
  </code></pre>
  
  <p><strong><em>But when I execute the same statement using the same .hql file after some time, it copies to local as expected.</em></strong> Can anyone please help me to understand why this happens?</p>
  
  <pre><code>Version: Hive 1.1.0-cdh5.8.3
  </code></pre>
  
  <p><strong>Update 1</strong>: I used "get" instead of "copyToLocal" and got the same exception.</p>
  
  <p><strong>Update 2</strong>: This file has <strong>sticky</strong> bit:</p>
  
  <pre><code>-rwxrwxrwt .....  /HDFS_FOLDER1/HDFS_FOLDER2/file_name.dat
  </code></pre>
  
  <p>I am the userwho created the file, and I am trying to copy it from HDFS to local folder using dfs option from HQL file.</p>