You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by uw...@apache.org on 2017/10/05 09:11:09 UTC

arrow git commit: ARROW-226: [C++] If opening an HDFS file fails and it does not exist, say so to help with debugging

Repository: arrow
Updated Branches:
  refs/heads/master 0f819fa73 -> 7511cfdd5


ARROW-226: [C++] If opening an HDFS file fails and it does not exist, say so to help with debugging

This was a rough edge that had affected some users

Author: Wes McKinney <we...@twosigma.com>

Closes #1166 from wesm/ARROW-226 and squashes the following commits:

7ab2891 [Wes McKinney] If opening an HDFS file fails and it does not exist, say so to help with debugging


Project: http://git-wip-us.apache.org/repos/asf/arrow/repo
Commit: http://git-wip-us.apache.org/repos/asf/arrow/commit/7511cfdd
Tree: http://git-wip-us.apache.org/repos/asf/arrow/tree/7511cfdd
Diff: http://git-wip-us.apache.org/repos/asf/arrow/diff/7511cfdd

Branch: refs/heads/master
Commit: 7511cfdd5e625e310b7943bfe1ab5f6e8a67b3b2
Parents: 0f819fa
Author: Wes McKinney <we...@twosigma.com>
Authored: Thu Oct 5 11:11:01 2017 +0200
Committer: Uwe L. Korn <uw...@xhochy.com>
Committed: Thu Oct 5 11:11:01 2017 +0200

----------------------------------------------------------------------
 cpp/src/arrow/io/hdfs.cc          | 8 ++++++--
 python/pyarrow/tests/test_hdfs.py | 9 +++++++++
 2 files changed, 15 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/arrow/blob/7511cfdd/cpp/src/arrow/io/hdfs.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/io/hdfs.cc b/cpp/src/arrow/io/hdfs.cc
index d9d4206..77d1f52 100644
--- a/cpp/src/arrow/io/hdfs.cc
+++ b/cpp/src/arrow/io/hdfs.cc
@@ -455,9 +455,13 @@ class HadoopFileSystem::HadoopFileSystemImpl {
     hdfsFile handle = driver_->OpenFile(fs_, path.c_str(), O_RDONLY, buffer_size, 0, 0);
 
     if (handle == nullptr) {
-      // TODO(wesm): determine cause of failure
       std::stringstream ss;
-      ss << "Unable to open file " << path;
+      if (!Exists(path)) {
+        ss << "HDFS file does not exist: " << path;
+      } else {
+        // TODO(wesm): determine other causes of failure
+        ss << "HDFS path exists, but opening file failed: " << path;
+      }
       return Status::IOError(ss.str());
     }
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/7511cfdd/python/pyarrow/tests/test_hdfs.py
----------------------------------------------------------------------
diff --git a/python/pyarrow/tests/test_hdfs.py b/python/pyarrow/tests/test_hdfs.py
index cbc2773..51b6ba2 100644
--- a/python/pyarrow/tests/test_hdfs.py
+++ b/python/pyarrow/tests/test_hdfs.py
@@ -213,6 +213,15 @@ class HdfsTestCases(object):
             result = f.read(10)
             assert result == data
 
+    def test_open_not_exist_error_message(self):
+        # ARROW-226
+        path = pjoin(self.tmp_path, 'does-not-exist-123')
+
+        try:
+            self.hdfs.open(path)
+        except Exception as e:
+            assert 'file does not exist' in e.args[0].lower()
+
     def test_read_whole_file(self):
         path = pjoin(self.tmp_path, 'read-whole-file')