-
Notifications
You must be signed in to change notification settings - Fork 261
fix: planner should error if join columns are missing #1104
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
base: main
Are you sure you want to change the base?
fix: planner should error if join columns are missing #1104
Conversation
4ce2128 to
7a54647
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1104 +/- ##
=======================================
Coverage 96.77% 96.77%
=======================================
Files 302 302
Lines 59220 59223 +3
=======================================
+ Hits 57310 57313 +3
Misses 1910 1910 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a bug in the join planner where missing join columns were silently ignored instead of raising an error. Previously, the code used filter_map which would skip over columns that couldn't be found in the table schemas, potentially leading to incorrect join operations. The fix changes to map and explicitly converts None values from get_index_of() to PlannerError::ColumnNotFound.
Key Changes
- Changed from
filter_maptomapin join column processing to ensure all columns are validated - Added explicit error handling using
ok_or(PlannerError::ColumnNotFound)?when join columns are not found in table schemas - This ensures the planner fails fast with a clear error message instead of silently continuing with incomplete join information
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| .map(|(left_expr, right_expr)| match (left_expr, right_expr) { | ||
| (Expr::Column(col_a), Expr::Column(col_b)) if col_a.name == col_b.name => { | ||
| let column_id = Ident::new(col_a.name.clone()); | ||
| Ok(( | ||
| ( | ||
| left_column_result_fields | ||
| .get_index_of(&column_id) | ||
| .ok_or(PlannerError::ColumnNotFound)?, | ||
| right_column_result_fields | ||
| .get_index_of(&column_id) | ||
| .ok_or(PlannerError::ColumnNotFound)?, | ||
| ), | ||
| column_id, | ||
| )) | ||
| } | ||
| _ => Err(PlannerError::UnsupportedLogicalPlan { | ||
| plan: Box::new(plan.clone()), | ||
| }), | ||
| }) |
Copilot
AI
Dec 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new error handling for missing join columns (ColumnNotFound errors on lines 334 and 337) lacks test coverage. Consider adding a test case that verifies a ColumnNotFound error is raised when join columns are not present in the left or right table schemas.
Example test structure:
#[test]
fn we_cannot_convert_join_with_missing_column() {
// Create tables where join column doesn't exist in one or both tables
// Attempt to join on the missing column
// Assert that result matches Err(PlannerError::ColumnNotFound)
}
Please be sure to look over the pull request guidelines here: https://github.com/spaceandtimelabs/sxt-proof-of-sql/blob/main/CONTRIBUTING.md#submit-pr.
Please go through the following checklist
!is used if and only if at least one breaking change has been introduced.source scripts/run_ci_checks.sh.source scripts/check_commits.sh, and the commit history is certified to follow clean commit guidelines as described here: https://github.com/spaceandtimelabs/sxt-proof-of-sql/blob/main/COMMIT_GUIDELINES.mdmainhave been incorporated to this PR by simple rebase if possible, if not, then conflicts are resolved appropriately.Rationale for this change
What changes are included in this PR?
Are these changes tested?