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

normalize "in" predicate as disjunction of "==" #423

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
21 changes: 10 additions & 11 deletions kartothek/serialization/_parquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,17 +555,16 @@ def _predicate_accepts(predicate, row_meta, arrow_schema, parquet_reader):
elif op == ">":
return max_value > val
elif op == "in":
# This implementation is chosen for performance reasons. See
# https://github.com/JDASoftwareGroup/kartothek/pull/130 for more information/benchmarks.
# We accept the predicate if there is any value in the provided array which is equal to or between
# the parquet min and max statistics. Otherwise, it is rejected.
for x in val:
if pd.isnull(x):
if parquet_statistics.null_count > 0:
return True
elif min_value <= x <= max_value:
return True
return False
# We don't duplicate the logic here, as "in" is just a disjunction of "=="'s
return any(
_predicate_accepts(
predicate=[col, "==", value],
row_meta=row_meta,
arrow_schema=arrow_schema,
parquet_reader=parquet_reader,
)
for value in val
)
else:
raise NotImplementedError("op not supported")

Expand Down