Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/3208#discussion_r20401128
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/complexTypes.scala
 ---
    @@ -55,7 +55,11 @@ case class GetItem(child: Expression, ordinal: 
Expression) extends Expression {
               // TODO: consider using Array[_] for ArrayType child to avoid
               // boxing of primitives
               val baseValue = value.asInstanceOf[Seq[_]]
    -          val o = key.asInstanceOf[Int]
    +          val o = key match {
    +            case k if k.isInstanceOf[Byte] => k.asInstanceOf[Byte]
    +            case k if k.isInstanceOf[Short] => k.asInstanceOf[Short]
    +            case k => k.asInstanceOf[Int]
    --- End diff --
    
    The runtime type checking here is not good. Thanks for your suggestion, I 
add the casting for `GetItem` and `Substring` in `FunctionArgumentConversion`.
    
    For the `resolved ` problem, since it is supported to use non `IntegerType` 
as `ordinal` (ref: test `apply schema` in `SQLQuerySuite`, to add this 
condition to `resolved` would case error. So I leave it as unmodified. 


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to