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

FIX-#4580: Fix access by row label in query and eval #6488

Conversation

mvashishtha
Copy link
Collaborator

What do these changes do?

query and eval raise exceptions as in #4580 on partitioned execution engines when given expressions that access elements by row label. I don't see a way to do distributed execution for query and eval other than doing what pandas does when using the python engine, which is to evaluate the expression as python (and then pass it into df.loc[result, :] for query). That's what I do in this PR.

So far I have been able to use pandas.DataFrame.query and pandas.DataFrame.eval directly without copying code. I prefer that for now because we would have to copy many methods.

Supporting the numexpr engine this way will take more work.

  • first commit message and PR title follow format outlined here

    NOTE: If you edit the PR title to match this format, you need to add another commit (even if it's empty) or amend your last commit for the CI job that checks the PR title to pick up the new PR title.

  • passes flake8 modin/ asv_bench/benchmarks scripts/doc_checker.py
  • passes black --check modin/ asv_bench/benchmarks scripts/doc_checker.py
  • signed commit with git commit -s
  • Resolves query and eval: accessing column data by position raises errors #4580
  • tests added and passing
  • module layout described at docs/development/architecture.rst is up-to-date

@mvashishtha mvashishtha marked this pull request as ready for review August 18, 2023 18:23
@mvashishtha mvashishtha requested a review from a team as a code owner August 18, 2023 18:23
Copy link
Collaborator

@devin-petersohn devin-petersohn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @mvashishtha!

@RehanSD RehanSD merged commit 29d9da0 into modin-project:master Aug 21, 2023
RehanSD pushed a commit that referenced this pull request Aug 22, 2023
RehanSD pushed a commit that referenced this pull request Aug 22, 2023
RehanSD pushed a commit that referenced this pull request Aug 22, 2023
Comment on lines -2480 to -2484
def query(self, expr, **kwargs):
def query_builder(df, **modin_internal_kwargs):
return df.query(expr, inplace=False, **kwargs, **modin_internal_kwargs)

return self.__constructor__(self._modin_frame.filter(1, query_builder))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After this PR we see about ~1.6x perf degradation for one of our internal workloads that uses simple queries a lot.

@mvashishtha can you please check #6499?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

query and eval: accessing column data by position raises errors
4 participants