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: Validate/coerce types for comparisons within join_where predicates #21049

Merged
merged 10 commits into from
Feb 5, 2025

Conversation

nameexhaustion
Copy link
Collaborator

@nameexhaustion nameexhaustion commented Feb 3, 2025

Adds a type validation / coercion step to join_where predicates. This ensures comparison expressions within the predicates have compatible dtypes (matching, or have a lossless supertype).

Drive-by

  • Renames the existing is_comparison() function to is_comparison_or_bitwise() to better reflect what it matches
  • Adjusts the casting to be overflowing as that (formally) permits more optimizations.

@github-actions github-actions bot added fix Bug fix python Related to Python Polars rust Related to Rust Polars labels Feb 3, 2025
@nameexhaustion nameexhaustion changed the title fix: Coerce types for join_where keys fix: Coerce types for join keys after join_where rewrite Feb 3, 2025
@nameexhaustion nameexhaustion force-pushed the join-where-key-type-coerce branch from a7df6fe to d216e4a Compare February 3, 2025 12:43
@nameexhaustion nameexhaustion force-pushed the join-where-key-type-coerce branch from d216e4a to 3693a97 Compare February 5, 2025 06:47
},
_ => true,
});
polars_ensure!( valid, InvalidOperation: "'join_where' predicate only refers to columns from a single table")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

check refactored to process_join_where_predicate() below

@nameexhaustion nameexhaustion changed the title fix: Coerce types for join keys after join_where rewrite fix: Validate and coerce types for comparisons within join_where predicates Feb 5, 2025
@nameexhaustion nameexhaustion changed the title fix: Validate and coerce types for comparisons within join_where predicates fix: Validate/coerce types for comparisons within join_where predicates Feb 5, 2025
Copy link

codecov bot commented Feb 5, 2025

Codecov Report

Attention: Patch coverage is 94.02985% with 12 lines in your changes missing coverage. Please review.

Project coverage is 79.27%. Comparing base (e17f4b2) to head (861e903).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
crates/polars-plan/src/plans/conversion/join.rs 93.70% 8 Missing ⚠️
...-plan/src/plans/conversion/type_coercion/binary.rs 50.00% 3 Missing ⚠️
...ates/polars-plan/src/plans/optimizer/join_utils.rs 96.87% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #21049      +/-   ##
==========================================
+ Coverage   79.19%   79.27%   +0.07%     
==========================================
  Files        1585     1585              
  Lines      226009   226132     +123     
  Branches     2592     2592              
==========================================
+ Hits       178985   179257     +272     
+ Misses      46429    46280     -149     
  Partials      595      595              

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

@nameexhaustion nameexhaustion marked this pull request as draft February 5, 2025 09:47
@nameexhaustion nameexhaustion marked this pull request as ready for review February 5, 2025 09:47
@ritchie46
Copy link
Member

@nameexhaustion I also got this python error? Any idea what it is?

@nameexhaustion
Copy link
Collaborator Author

@nameexhaustion I also got this python error? Any idea what it is?

I will make a PR to fix

@nameexhaustion
Copy link
Collaborator Author

@ritchie46 ritchie46 merged commit ebb513c into pola-rs:main Feb 5, 2025
27 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
2 participants