0lai0 commented on code in PR #5050:
URL: https://github.com/apache/datafusion-comet/pull/5050#discussion_r4307692004


##########
docs/source/user-guide/latest/compatibility/expressions/_category_template/cast.md:
##########
@@ -165,6 +165,22 @@ Spark's behavior of using Java `BigDecimal.toString()` 
semantics, which produces
 notation (e.g. a value of 12300 stored as `Decimal(7,-2)` with unscaled value 
123 is rendered
 as `"1.23E+4"`).
 
+## Decimal with Negative Scale to Integer and Timestamp
+
+Casting a `DecimalType` with a negative scale to `ByteType`, `ShortType`, 
`IntegerType`,
+`LongType` or `TimestampType` has no native implementation, and neither does 
casting any of the
+integer types to a negative-scale `DecimalType`. Comet reports these as 
unsupported, which
+routes them through the JVM codegen dispatcher (Spark's own generated code) 
inside the Comet
+pipeline, so the results match Spark exactly.
+
+The native kernels align scale by computing `10^|scale|` in fixed-point 
arithmetic, which
+overflows when the scale is negative. See
+[#5013](https://github.com/apache/datafusion-comet/issues/5013).
+
+All other cast directions to and from negative-scale decimals run natively: 
`FloatType` and
+`DoubleType`, `StringType` in both directions (subject to the config gate 
described above),
+`BooleanType`, and widening to another `DecimalType`.

Review Comment:
   Fixed. It now says casts from a negative-scale decimal to `BooleanType`, and 
adds that the other direction goes through the dispatcher at any scale, since 
that is not specific to a negative one.



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