Github user chenghao-intel commented on a diff in the pull request:

    https://github.com/apache/spark/pull/7151#discussion_r33683599
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/HiveTypeCoercion.scala
 ---
    @@ -705,13 +705,13 @@ object HiveTypeCoercion {
        * Casts types according to the expected input types for Expressions 
that have the trait
        * [[AutoCastInputTypes]].
        */
    -  object AddCastForAutoCastInputTypes extends Rule[LogicalPlan] {
    +  object ImplicitTypeCasts extends Rule[LogicalPlan] {
         def apply(plan: LogicalPlan): LogicalPlan = plan 
transformAllExpressions {
           // Skip nodes who's children have not been resolved yet.
           case e if !e.childrenResolved => e
     
    -      case e: AutoCastInputTypes if e.children.map(_.dataType) != 
e.expectedChildTypes =>
    -        val newC = (e.children, e.children.map(_.dataType), 
e.expectedChildTypes).zipped.map {
    +      case e: AutoCastInputTypes if e.children.map(_.dataType) != 
e.inputTypes =>
    +        val newC = (e.children, e.children.map(_.dataType), 
e.inputTypes).zipped.map {
               case (child, actual, expected) =>
                 if (actual == expected) child else Cast(child, expected)
    --- End diff --
    
    The original logic probably a bug. 
    Let's say:
    The expression "printf(format, ...)", we expect the first parameter to be 
`StringType`, thus any other type (e.g. `IntegerType`) can be casted to 
`StringType`, but doesn't mean we have to accept the casting for its child.
    
    The same for the other string expression like `Subtring(str, pos, len)`, 
predicates, misc etc.
    Actually I doubt we have the real case to accept the auto casting, except 
the mathmatic expressions.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to