kosiew commented on code in PR #24851:
URL: https://github.com/apache/datafusion/pull/24851#discussion_r3949765694


##########
datafusion/expr-common/src/type_coercion/binary/tests/comparison.rs:
##########
@@ -1093,3 +1093,34 @@ fn test_string_concat_coercion() -> Result<()> {
 
     Ok(())
 }
+
+/// `Decimal256` allows a precision and a scale of up to 76, so the required
+/// precision `max(s1, s2) + max(p1 - s1, p2 - s2)` can reach 228 and the
+/// intermediate `p - s` can reach 152. Neither fits in the `i8` used for
+/// decimal scales, which used to panic with "attempt to add with overflow"
+/// (or "attempt to subtract with overflow") in debug builds.
+#[test]
+fn test_decimal256_comparison_coercion_precision_overflow() -> Result<()> {

Review Comment:
   Nice to see the coercion regression covered here. Since the original issue 
is also reachable through SQL planning, it might be worth adding the exact 
`CAST(1 AS DECIMAL(76,0)) < CAST(2 AS DECIMAL(76,52))` case to the decimal 
SQLLogicTest suite as well. That would give us coverage through the parser and 
type-planning path. Not a blocker since this unit test already covers the 
underlying coercion fix.



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