haohuaijin opened a new pull request, #25528:
URL: https://github.com/apache/datafusion/pull/25528

   ## Which issue does this PR close?
   
   Closes #25524.
   Related to #25407 and #22028.
   
   ## Rationale for this change
   
   A valid query can fail when an inferred numeric interval extends beyond the 
target CAST type, even though every runtime value fits. For example, an 
expression that always evaluates to zero can have an estimated upper bound of 
1000 and fail when cast to TINYINT during planning.
   
   ## What changes are included in this PR?
   
   Use safe Arrow casts for numeric interval endpoints in `Interval::cast_to`, 
independently of the runtime cast error policy. An endpoint that cannot be 
represented becomes unbounded, while a valid opposite endpoint is retained. 
Non-numeric conversions continue to honor the supplied cast options, and errors 
returned by the cast kernel are still propagated.
   
   ## What is the testing strategy for this PR?
   
   - Add regression cases to the existing `cast.slt` for positive and negative 
inferred overflow, ordinary CAST runtime errors, and TRY_CAST runtime NULL 
results.
   - Add unit coverage for numeric narrowing, signed/unsigned conversions, 
decimal precision and scale changes, fractional values, existing unbounded 
endpoints, and non-numeric error handling.
   - Check sampled value containment across 14 numeric types with both safe 
option settings.
   - Validated expr-common unit tests, physical-expr and pruning unit tests, 
and six relevant SLT files covering casts, filter ordering, and filter pushdown.
   
   ## Are there any user-facing changes?
   
   Valid queries no longer fail solely because inferred numeric cast endpoints 
are out of range. Runtime CAST and TRY_CAST behavior is unchanged.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to