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(rust, python): Clear window cache after evaluate predication expr #10505

Merged
merged 3 commits into from
Aug 17, 2023

Conversation

reswqa
Copy link
Collaborator

@reswqa reswqa commented Aug 15, 2023

This fixes #10499.

@github-actions github-actions bot added fix Bug fix python Related to Python Polars rust Related to Rust Polars labels Aug 15, 2023
@@ -35,6 +35,9 @@ impl Executor for FilterExec {
state.insert_has_window_function_flag()
}
let s = self.predicate.evaluate(&df, state)?;
if state.cache_window() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Might replace this by if has_window to reduce the overhead of atomic load? 🤔

Copy link
Member

Choose a reason for hiding this comment

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

Yes an you put the cache_window and the clear_window_expr behind a if self.has_windows?

Copy link
Collaborator Author

@reswqa reswqa Aug 16, 2023

Choose a reason for hiding this comment

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

Do you mean to replace it with

if self.has_window() && state.cache_window() {
   state.clear_window_expr_cache();
}

Copy link
Member

@ritchie46 ritchie46 Aug 17, 2023

Choose a reason for hiding this comment

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

This is what we do during projection.

    if has_windows {
        state.clear_window_expr_cache();
    }

I believe the && state.cache_window() is redundant as it should always be set if has_windows is true.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I see, removed it.

Copy link
Member

@ritchie46 ritchie46 left a comment

Choose a reason for hiding this comment

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

Nice @reswqa. Great analysis.

I have left some comments.

@@ -35,6 +35,9 @@ impl Executor for FilterExec {
state.insert_has_window_function_flag()
}
let s = self.predicate.evaluate(&df, state)?;
if state.cache_window() {
Copy link
Member

Choose a reason for hiding this comment

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

Yes an you put the cache_window and the clear_window_expr behind a if self.has_windows?

crates/polars-lazy/src/physical_plan/executors/scan/mod.rs Outdated Show resolved Hide resolved
crates/polars-lazy/src/physical_plan/executors/scan/mod.rs Outdated Show resolved Hide resolved
@reswqa
Copy link
Collaborator Author

reswqa commented Aug 16, 2023

Thanks @ritchie46 for the review. I have updated this, but I'm not sure if I totally understand all comments, so feel free to append new comments.

@reswqa
Copy link
Collaborator Author

reswqa commented Aug 17, 2023

The redundant state.cache_window() has been removed.

@ritchie46
Copy link
Member

Alright! 🙌

@ritchie46 ritchie46 merged commit fb61d30 into pola-rs:main Aug 17, 2023
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Bug fix python Related to Python Polars rust Related to Rust Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multiple filters in LazyFrame on same column throws shape error
2 participants