Skip to content

Conversation

MazterQyou
Copy link
Member

Check List

  • Tests have been run in packages where changes made if available
  • Linter has been run for changed code
  • Tests for the changes have been added if not covered yet
  • Docs have been added / updated if required

Description of Changes Made

This PR extends FilterMetaSplit optimizer to push down __user filter as much as possible. This solves an issue with SQL push down queries with joins and multiple __user filters being part of the generated SQL.
Related test is included.

Signed-off-by: Alex Qyoun-ae <4062971+MazterQyou@users.noreply.github.com>
@MazterQyou MazterQyou requested a review from a team as a code owner June 25, 2025 16:01
Copy link

codecov bot commented Jun 25, 2025

Codecov Report

Attention: Patch coverage is 94.96124% with 13 lines in your changes missing coverage. Please review.

Project coverage is 84.19%. Comparing base (2d66576) to head (490f51f).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
.../compile/engine/df/optimizers/filter_split_meta.rs 93.71% 13 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #9711       +/-   ##
===========================================
+ Coverage        0   84.19%   +84.19%     
===========================================
  Files           0      230      +230     
  Lines           0    85318    +85318     
===========================================
+ Hits            0    71837    +71837     
- Misses          0    13481    +13481     
Flag Coverage Δ
cubesql 84.19% <94.96%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 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.

Copy link
Member

@KSDaemon KSDaemon left a comment

Choose a reason for hiding this comment

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

👍🏻 LGTM. Left minor code change (optional)...

Comment on lines +363 to +376
let predicates_iter = predicates.into_iter();
if reverse {
predicates_iter.rev().reduce(|last, next| Expr::BinaryExpr {
left: Box::new(last),
op: Operator::And,
right: Box::new(next),
})
.ok_or_else(|| {
DataFusionError::Internal(
"Unable to optimize plan: can't concatenate predicates, vec is unexpectedly empty"
.to_string(),
)
} else {
predicates_iter.reduce(|last, next| Expr::BinaryExpr {
left: Box::new(last),
op: Operator::And,
right: Box::new(next),
})
}
Copy link
Member

Choose a reason for hiding this comment

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

Mb smth like:

let predicates_iter = predicates.into_iter();
let predicates_iter = if reverse { predicates_iter.rev() } else { predicates_iter };
predicates_iter.reduce(|last, next| Expr::BinaryExpr {
            left: Box::new(last),
            op: Operator::And,
            right: Box::new(next),
        })

No copy/paste...

Copy link
Member Author

Choose a reason for hiding this comment

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

I wanted to do the same but they're different structures, so can't really be put in the same let.

@MazterQyou MazterQyou merged commit 5dd626a into master Jun 25, 2025
84 checks passed
@MazterQyou MazterQyou deleted the cubesql/user-change-optimizer-sql-push-down branch June 25, 2025 16:45
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.

2 participants