0lai0 commented on code in PR #5050:
URL: https://github.com/apache/datafusion-comet/pull/5050#discussion_r4307626322
##########
spark/src/main/scala/org/apache/comet/expressions/CometCast.scala:
##########
@@ -511,12 +527,26 @@ object CometCast
private def canCastFromDecimal(fromType: DecimalType, toType: DataType):
SupportLevel =
toType match {
- case DataTypes.ByteType | DataTypes.ShortType | DataTypes.IntegerType |
DataTypes.LongType
- if fromType.scale < 0 =>
- Unsupported(Some(negativeScaleDecimalToIntegralReason))
- case DataTypes.FloatType | DataTypes.DoubleType | DataTypes.ByteType |
DataTypes.ShortType |
- DataTypes.IntegerType | DataTypes.LongType | DataTypes.BooleanType |
- DataTypes.TimestampType =>
+ // The integral and timestamp kernels scale-align through a power of ten
that overflows for
+ // a negative scale. Matching each target group once keeps the scale
check next to the list
+ // it applies to. See issue #5013.
+ case DataTypes.ByteType | DataTypes.ShortType | DataTypes.IntegerType |
+ DataTypes.LongType =>
+ if (fromType.scale < 0) {
+ Unsupported(Some(negativeScaleDecimalToIntegralReason))
+ } else {
+ Compatible()
+ }
+ case DataTypes.TimestampType =>
+ if (fromType.scale < 0) {
+ Unsupported(Some(negativeScaleDecimalToTimestampReason))
+ } else {
+ Compatible()
+ }
+ // Float and double are not gated on scale: `decimal128_to_f64` /
`decimal128_to_f32`
+ // round the exact decimal value once and handle a negative scale
deliberately (#5684).
+ case DataTypes.FloatType | DataTypes.DoubleType | DataTypes.BooleanType
=>
+ Compatible()
Compatible()
Review Comment:
Mine from the #6953 merge. Dropped.
--
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]