mirror of
https://github.com/apache/arrow.git
synced 2026-10-28 16:47:19 +08:00
Handle Python3 strings correctly
This commit is contained in:
1 parent
066c08afc1
commit
4a80116ef2
1 file changed
+4
-2
@@ -23,6 +23,7 @@ from pyarrow.includes.libarrow cimport *
|
||||
cimport pyarrow.includes.pyarrow as pyarrow
|
||||
from pyarrow.includes.parquet cimport *
|
||||
|
||||
from pyarrow.compat import tobytes
|
||||
from pyarrow.error cimport check_cstatus
|
||||
from pyarrow.table cimport Table
|
||||
|
||||
@@ -40,7 +41,7 @@ def read_table(filename, columns=None):
|
||||
# Must be in one expression to avoid calling std::move which is not possible
|
||||
# in Cython (due to missing rvalue support)
|
||||
reader = unique_ptr[FileReader](new FileReader(default_memory_pool(),
|
||||
ParquetFileReader.OpenFile(filename)))
|
||||
ParquetFileReader.OpenFile(tobytes(filename))))
|
||||
check_cstatus(reader.get().ReadFlatTable(&ctable))
|
||||
table.init(ctable)
|
||||
return table
|
||||
@@ -58,7 +59,8 @@ def write_table(table, filename, chunk_size=None):
|
||||
"""
|
||||
cdef Table table_ = table
|
||||
cdef CTable* ctable_ = table_.table
|
||||
cdef shared_ptr[OutputStream] sink = shared_ptr[OutputStream](new LocalFileOutputStream(filename))
|
||||
cdef shared_ptr[OutputStream] sink = shared_ptr[OutputStream](
|
||||
new LocalFileOutputStream(tobytes(filename)))
|
||||
cdef int64_t chunk_size_ = 0
|
||||
if chunk_size is None:
|
||||
chunk_size_ = min(ctable_.num_rows(), int(2**16))
|
||||
|
||||
Reference in new issue
Block a user