Allow expression to report whether they keep the same ordering of the input (a.cmp(b) == f(a).cmp(f(b))) opening up for more optimization#23807
Conversation
a.cmp(b) == f(a).cmp(f(b)) opening up for more optimization
e0c40b1 to
7305547
Compare
|
Thank you for opening this pull request! Reviewer note: cargo-semver-checks reported the current version number is not SemVer-compatible with the changes in this pull request (compared against the base branch). Details |
a.cmp(b) == f(a).cmp(f(b)) opening up for more optimizationa.cmp(b) == f(a).cmp(f(b))) opening up for more optimization
| if is_order_preserving_cast_family(&child.range.data_type(), target_type) { | ||
| Ok(child.clone().with_range(unbounded)) | ||
| let source_type = child.range.data_type(); | ||
| // A widening cast is additionally one-to-one, so it is strictly |
There was a problem hiding this comment.
I may not have full context, so please feel free to ignore this if it's a misunderstanding.
CastExpr::check_bigger_cast includes Int32 -> Float32 and Int64 -> Float64. Due to float mantissa limits, large integers lose precision and can collapse to the same float value (e.g. 16_777_216_i32 as f32 == 16_777_217_i32 as f32), so they are not strictly 1-to-1
There was a problem hiding this comment.
You are right, unfortunately this moved from here (so no logic change has been made):
| preserves_lex_ordering: value.preserves_lex_ordering, | ||
| // Not carried over the FFI boundary (it would break the ABI); | ||
| // stay conservative. | ||
| strictly_order_preserving: false, |
There was a problem hiding this comment.
Should I make breaking change in FFI (by adding the field) while I'm here to avoid 2 breaking changes? I'm not really familiar with this module
| if is_order_preserving_cast_family(&child.range.data_type(), target_type) { | ||
| Ok(child.clone().with_range(unbounded)) | ||
| let source_type = child.range.data_type(); | ||
| // A widening cast is additionally one-to-one, so it is strictly |
There was a problem hiding this comment.
You are right, unfortunately this moved from here (so no logic change has been made):
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #23807 +/- ##
==========================================
+ Coverage 80.69% 80.71% +0.02%
==========================================
Files 1089 1089
Lines 368447 368979 +532
Branches 368447 368979 +532
==========================================
+ Hits 297332 297836 +504
+ Misses 53405 53376 -29
- Partials 17710 17767 +57 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Which issue does this PR close?
Related to:
Rationale for this change
To be able to keep the same sorting order allowing for more optimizations
Now comet own
castimplementation can be recognized as not modifying sort order in the same cases that datafusion cast does.What changes are included in this PR?
added
strictly_order_preservingproperty toExprProperties+ varius other placesand replaced the hard coded logic for cast (
substitute_cast_ordering) about keeping input order with more generic approach that now any expression can implement and have the same advantage of sort eliminationAre these changes tested?
yes
Are there any user-facing changes?
yes, breaking change, added
strictly_order_preservingproperty toExprProperties