You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by we...@apache.org on 2019/06/19 13:46:25 UTC

[arrow] branch master updated: ARROW-4823: [C++][Python] Do not close raw file handle in ReadaheadSpooler, check that file handles passed to read_csv are not closed

This is an automated email from the ASF dual-hosted git repository.

wesm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/master by this push:
     new a155182  ARROW-4823: [C++][Python] Do not close raw file handle in ReadaheadSpooler, check that file handles passed to read_csv are not closed
a155182 is described below

commit a155182f6955cca170fe7662cad4cb5f453eaffe
Author: Wes McKinney <we...@apache.org>
AuthorDate: Wed Jun 19 08:46:17 2019 -0500

    ARROW-4823: [C++][Python] Do not close raw file handle in ReadaheadSpooler, check that file handles passed to read_csv are not closed
    
    Author: Wes McKinney <we...@apache.org>
    
    Closes #4610 from wesm/ARROW-4823 and squashes the following commits:
    
    5d13f23e6 <Wes McKinney> Do not close raw file handle in ReadaheadSpooler and check that this flows through to fix reported issue with pyarrow.csv.read_csv
---
 cpp/src/arrow/io/readahead-test.cc | 4 ++++
 cpp/src/arrow/io/readahead.cc      | 2 +-
 python/pyarrow/tests/test_csv.py   | 7 +++++++
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/cpp/src/arrow/io/readahead-test.cc b/cpp/src/arrow/io/readahead-test.cc
index 000a62d..fadd4df 100644
--- a/cpp/src/arrow/io/readahead-test.cc
+++ b/cpp/src/arrow/io/readahead-test.cc
@@ -193,8 +193,12 @@ TEST(ReadaheadSpooler, Close) {
 
   AssertEventualPosition(*data_reader, 2 * 2);
   ASSERT_OK(spooler.Close());
+
   // Idempotency
   ASSERT_OK(spooler.Close());
+
+  // ARROW-4823: does not close raw
+  ASSERT_FALSE(data_reader->closed());
 }
 
 TEST(ReadaheadSpooler, Paddings) {
diff --git a/cpp/src/arrow/io/readahead.cc b/cpp/src/arrow/io/readahead.cc
index 4222f87..fd00414 100644
--- a/cpp/src/arrow/io/readahead.cc
+++ b/cpp/src/arrow/io/readahead.cc
@@ -67,7 +67,7 @@ class ReadaheadSpooler::Impl {
       io_worker_.join();
       lock.lock();
     }
-    return raw_->Close();
+    return Status::OK();
   }
 
   Status Read(ReadaheadBuffer* out) {
diff --git a/python/pyarrow/tests/test_csv.py b/python/pyarrow/tests/test_csv.py
index fc85406..e3c1c37 100644
--- a/python/pyarrow/tests/test_csv.py
+++ b/python/pyarrow/tests/test_csv.py
@@ -495,3 +495,10 @@ class TestBZ2CSVRead(BaseTestCompressedCSVRead, unittest.TestCase):
     def write_file(self, path, contents):
         with bz2.BZ2File(path, 'w') as f:
             f.write(contents)
+
+
+def test_read_csv_does_not_close_passed_file_handles():
+    # ARROW-4823
+    buf = io.BytesIO(b"a,b,c\n1,2,3\n4,5,6")
+    read_csv(buf)
+    assert not buf.closed