sunchao opened a new pull request, #7806:
URL: https://github.com/apache/datafusion-comet/pull/7806

   Closes #7805.
   
   ## Why are the changes needed?
   
   In ANSI mode, Comet raises `CAST_OVERFLOW` when a decimal truncates to the 
minimum `INT` or `BIGINT`. The kernel compares the absolute value against the 
positive maximum. For example, `-2147483648` fits in an `INT`, but its 
magnitude exceeds `2147483647` by one.
   
   ## What changes were proposed in this PR?
   
   Use `i32::try_from` and `i64::try_from` in the shared native kernel after 
truncating the decimal toward zero. The checked conversion accepts both signed 
bounds and maps out-of-range values to `CAST_OVERFLOW`.
   
   ## How was this PR tested?
   
   The SQL regression reads decimal columns from Parquet so Spark evaluates the 
casts at runtime. For both destination types, it checks that `MIN` and `MIN − 
0.5` produce `MIN` in a native projection and match Spark. Separate queries 
check that `MIN − 1` raises `CAST_OVERFLOW` for each type. The existing fixture 
runs with Parquet dictionary encoding enabled and disabled.
   


-- 
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