Skip to content

fix: make restricted_column run linearly - #25908

Open
gafiatulin wants to merge 5 commits into
apache:mainfrom
gafiatulin:fix/quadratic-in-list
Open

gafiatulin wants to merge 5 commits into
apache:mainfrom
gafiatulin:fix/quadratic-in-list

Conversation

@gafiatulin

Copy link
Copy Markdown

Which issue does this PR close?

What is the testing strategy for this PR?

Unit tests

Are there any user-facing changes?

No, only internal implementation.

@github-actions github-actions Bot added the physical-plan Changes to the physical-plan crate label Sep 30, 2026
@neilconway
neilconway self-requested a review October 1, 2026 20:56
@codecov-commenter

codecov-commenter commented Oct 1, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.71429% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.77%. Comparing base (06aa131) to head (dd7ac25).

Files with missing lines Patch % Lines
datafusion/physical-plan/src/filter.rs 85.71% 2 Missing and 13 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #25908      +/-   ##
==========================================
- Coverage   82.77%   82.77%   -0.01%     
==========================================
  Files        1147     1147              
  Lines      450909   450981      +72     
  Branches   450909   450981      +72     
==========================================
+ Hits       373252   373306      +54     
- Misses      54934    54941       +7     
- Partials    22723    22734      +11     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@neilconway neilconway left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks reasonable overall!

Comment thread datafusion/physical-plan/src/filter.rs Outdated
Comment on lines +1121 to +1127
if !statistics
.column_statistics
.iter()
.any(|column| holds_each_value_once(column, &statistics.num_rows))
{
return None;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is still coarse: if the table has a column that satisfies holds_each_value_once but that column is a different one than the predicate is being applied to, we still do a bunch of wasted work below. We could revise this to make the check more precise -- wdyt?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yeah, I guess specific column check can happen inside restricted_column prior to building the set. I'll make the change

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Would something like 247c956 work?

Comment thread datafusion/physical-plan/src/filter.rs Outdated
}

#[test]
fn test_filter_statistics_large_in_list() -> Result<()> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What if we extended test_filter_statistics_in_list_on_a_unique_column rather than adding a brand new test that overlaps with it?

@gafiatulin gafiatulin Oct 9, 2026 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done in dd7ac25

@github-actions github-actions Bot added the auto detected api change Auto detected API change label Oct 8, 2026
@gafiatulin
gafiatulin force-pushed the fix/quadratic-in-list branch from 2b1482d to dd7ac25 Compare October 9, 2026 10:38
@github-actions github-actions Bot removed the auto detected api change Auto detected API change label Oct 9, 2026
@gafiatulin
gafiatulin force-pushed the fix/quadratic-in-list branch from dd7ac25 to 29317cc Compare October 19, 2026 21:21
@gafiatulin
gafiatulin force-pushed the fix/quadratic-in-list branch from 29317cc to 58f5492 Compare October 19, 2026 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

physical-plan Changes to the physical-plan crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Planning time grows quadratically with IN-list size on main

3 participants