jorisvandenbossche commented on code in PR #13409:
URL: https://github.com/apache/arrow/pull/13409#discussion_r1038154782
##########
python/pyarrow/_dataset.pyx:
##########
@@ -385,6 +416,32 @@ cdef class Dataset(_Weakrefable):
"""The common schema of the full Dataset"""
return pyarrow_wrap_schema(self.dataset.schema())
+ def filter(self, expression):
+ """
+ Apply a row filter to the dataset.
+
+ Parameters
+ ----------
+ expression : Expression
+ The filter that should be applied to the dataset.
+
+ Returns
+ -------
+ Dataset
+ """
+ cdef:
+ Dataset filtered_dataset
+
+ new_filter = expression
+ current_filter = self._scan_options.get("filter")
+ if current_filter is not None and new_filter is not None:
+ new_filter = current_filter & new_filter
Review Comment:
> But I don't see what .filter(None) could mean if not to unset the current
filter.
For me the simplest interpretation would be to "not add any new filter".
Users don't necessarily have the concept of "current filter" in their mind.
The dataset is already filtered at that point, and then `filter(None)` would
just not filter it any further.
> Would you prefer a dedicated `Dataset.reset_filter()` method?
We could also defer that until there are some actual use cases / requests
for this? I am not sure if there is a good use case to first filter and then
reset it to be able to call get_fragments (except while interactively
exploring, but in such a case you can also easily recreate the object)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]