Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion cpp/src/arrow/python/inference.cc
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ class TypeInferrer {

if (obj == Py_None || internal::PyFloat_IsNaN(obj)) {
++none_count_;
} else if (PyBool_Check(obj)) {
} else if (internal::PyBoolScalar_Check(obj)) {
++bool_count_;
*keep_going = make_unions_;
} else if (internal::PyFloatScalar_Check(obj)) {
Expand Down Expand Up @@ -583,5 +583,20 @@ Status InferArrowTypeAndSize(PyObject* obj, int64_t* size,
return Status::OK();
}

ARROW_EXPORT
bool IsPyBool(PyObject* obj) {
return internal::PyBoolScalar_Check(obj);
}

ARROW_EXPORT
bool IsPyInt(PyObject* obj) {
return internal::PyIntScalar_Check(obj);
}

ARROW_EXPORT
bool IsPyFloat(PyObject* obj) {
return internal::PyFloatScalar_Check(obj);
}

} // namespace py
} // namespace arrow
9 changes: 9 additions & 0 deletions cpp/src/arrow/python/inference.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ class Status;

namespace py {

ARROW_EXPORT
bool IsPyBool(PyObject* obj);

ARROW_EXPORT
bool IsPyInt(PyObject* obj);

ARROW_EXPORT
bool IsPyFloat(PyObject* obj);

// These three functions take a sequence input, not arbitrary iterables
ARROW_EXPORT
arrow::Status InferArrowType(PyObject* obj, std::shared_ptr<arrow::DataType>* out_type);
Expand Down
4 changes: 4 additions & 0 deletions cpp/src/arrow/python/numpy-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ inline bool PyIntScalar_Check(PyObject* obj) {
return PyLong_Check(obj) || PyArray_IsScalar(obj, Integer);
}

inline bool PyBoolScalar_Check(PyObject* obj) {
return PyBool_Check(obj) || PyArray_IsScalar(obj, Bool);
}

} // namespace internal

} // namespace py
Expand Down
8 changes: 5 additions & 3 deletions python/pyarrow/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ def _isfilestore(self):

def read_parquet(self, path, columns=None, metadata=None, schema=None,
use_threads=True, nthreads=None,
use_pandas_metadata=False):
use_pandas_metadata=False, filters=None,
exact_filter_evaluation=True):
"""
Read Parquet data from path in file system. Can read from a single file
or a directory of files
Expand Down Expand Up @@ -179,9 +180,10 @@ def read_parquet(self, path, columns=None, metadata=None, schema=None,
from pyarrow.util import _deprecate_nthreads
use_threads = _deprecate_nthreads(use_threads, nthreads)
dataset = ParquetDataset(path, schema=schema, metadata=metadata,
filesystem=self)
filesystem=self, filters=filters)
return dataset.read(columns=columns, use_threads=use_threads,
use_pandas_metadata=use_pandas_metadata)
use_pandas_metadata=use_pandas_metadata,
exact_filter_evaluation=exact_filter_evaluation)

def open(self, path, mode='rb'):
"""
Expand Down
6 changes: 6 additions & 0 deletions python/pyarrow/includes/libarrow.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -1064,6 +1064,12 @@ cdef extern from 'arrow/python/config.h' namespace 'arrow::py':
void set_numpy_nan(object o)


cdef extern from 'arrow/python/inference.h' namespace 'arrow::py':
c_bool IsPyBool(object o)
c_bool IsPyInt(object o)
c_bool IsPyFloat(object o)


cdef extern from 'arrow/python/benchmark.h' namespace 'arrow::py::benchmark':
void Benchmark_PandasObjectIsNull(object lst) except *

Expand Down
Loading