Smallfu666 opened a new issue, #6200:
URL: https://github.com/apache/datafusion-comet/issues/6200

   ### Describe the bug
   
   `CometCast.isSupported` combines the support levels of nested casts by 
returning the first one
   that is not `Compatible`. That happens in the struct to struct arm, the 
struct to string arm, and
   the map arm (key before value). When an earlier child is `Incompatible` and 
a later one is
   `Unsupported`, the whole cast reports `Incompatible`.
   
   With `spark.comet.expr.allowIncompatible=true` that cast then runs natively, 
even though one of its
   children is not supported natively. Without the flag it goes to the codegen 
dispatcher, like
   `Unsupported` would.
   
   Today the only `Incompatible` cast is a negative-scale decimal to string with
   `spark.sql.legacy.allowNegativeScaleOfDecimal=false`, and such a decimal 
cannot normally be
   constructed while that flag is off. So this is hard to reach. It came up in 
#6179, where a TRY
   cast of a map key that can fail is `Unsupported` and could be masked this 
way.
   
   ### Steps to reproduce
   
   Found by reading the code, not reproduced end to end. For example:
   
   ```scala
   CometCast.isSupported(
     StructType(Seq(StructField("a", DecimalType(10, -2)), StructField("b", 
MapType(LongType, IntegerType)))),
     StructType(Seq(StructField("a", StringType), StructField("b", 
MapType(IntegerType, IntegerType)))),
     None,
     CometEvalMode.TRY)
   ```
   
   reports `Incompatible` (from field `a`) rather than `Unsupported` (from 
field `b`).
   
   ### Expected behavior
   
   `Unsupported` in any child wins over `Incompatible`, and `Incompatible` wins 
over `Compatible`.
   
   ### Additional context
   
   The struct to struct arm has returned the first non-Compatible field since 
712658e29 (2024).
   


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