Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow pyarrow.dataset.Expression in filters kwarg of deltalake.DeltaTable.to_pyarrow_table #2597

Closed
giacomorebecchi opened this issue Jun 14, 2024 · 0 comments · Fixed by #2600
Labels
enhancement New feature or request

Comments

@giacomorebecchi
Copy link
Contributor

Description

I would like to have more flexibility in using the filters kwarg in the method to_pyarrow_table, in particular by providing directly a pyarrow.dataset.Expression.

Use Case
In my use case, this is due to the fact that I want to be able to filter out null values, particularly by using a version of this issue:

Related Issue(s)
Also, note that this PR might be an occasion to reduce code duplication by removing this function:

def _filters_to_expression(filters: FilterType) -> Expression:
"""
Check if filters are well-formed and convert to an [pyarrow.dataset.Expression].
"""
if isinstance(filters[0][0], str):
# We have encountered the situation where we have one nesting level too few:
# We have [(,,), ..] instead of [[(,,), ..]]
dnf = cast(FilterDNFType, [filters])
else:
dnf = cast(FilterDNFType, filters)
dnf = _check_dnf(dnf, check_null_strings=False)
disjunction_members = []
for conjunction in dnf:
conjunction_members = [
_convert_single_predicate(col, op, val) for col, op, val in conjunction
]
disjunction_members.append(reduce(operator.and_, conjunction_members))
return reduce(operator.or_, disjunction_members)

in favour of this:
https://github.com/apache/arrow/blob/69e8a78c018da88b60f9eb2b3b45703f81f3c93d/python/pyarrow/parquet/core.py#L135-L199

@giacomorebecchi giacomorebecchi added the enhancement New feature or request label Jun 14, 2024
giacomorebecchi pushed a commit to giacomorebecchi/delta-rs that referenced this issue Jun 14, 2024
giacomorebecchi pushed a commit to giacomorebecchi/delta-rs that referenced this issue Jun 14, 2024
giacomorebecchi pushed a commit to giacomorebecchi/delta-rs that referenced this issue Jun 14, 2024
ion-elgreco pushed a commit to giacomorebecchi/delta-rs that referenced this issue Jun 14, 2024
giacomorebecchi pushed a commit to giacomorebecchi/delta-rs that referenced this issue Jun 16, 2024
ion-elgreco pushed a commit to giacomorebecchi/delta-rs that referenced this issue Jun 16, 2024
giacomorebecchi pushed a commit to giacomorebecchi/delta-rs that referenced this issue Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant