feat: Implement preimage for ceil and round functions#22656
Open
kumarlokesh wants to merge 1 commit into
Open
Conversation
6227ffc to
fe01089
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
preimageforceilandroundfunctions #20197.Rationale for this change
floor(col) = Nis already rewritten viaScalarUDFImpl::preimageso thatpredicates push into Parquet row-group statistics.
ceilandroundadmitthe same rewrite but have boundary conventions that don't fit the API's
half-open
[lower, upper)form:ceil(x) = Nis(N-1, N], andround(x) = Nis sign-dependent under half-away-from-zero. Both can be expressed in
[lower, upper)form by shifting closed boundaries withf::next_up()What changes are included in this PR?
CeilFunc::preimage- Float32/Float64 and all four Decimal variants.RoundFunc::preimage- Float32/Float64 (with optional literaldp) and allfour Decimal variants for
dp = 0.ceil_preimage_float/ceil_preimage_decimalinceil.rs,round_preimage_float/round_preimage_decimalinround.rs.FloatExttrait in each file bridgingnum_traits::Floattof32::next_up()/f64::next_up().No changes to the preimage API, the simplifier, or any optimizer rule.
Are these changes tested?
Yes.
non-finite cases for both float and decimal variants.
ceil_preimage.slt,round_preimage.slt) cover data correctnessand
EXPLAINoutput for all six comparison operators plusIS (NOT) DISTINCT FROMandIN/NOT IN.Are there any user-facing changes?
No public API change. The optimization is transparent and predicate semantics
are preserved exactly.