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

    https://github.com/apache/spark/pull/1586#discussion_r15517240
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringOperations.scala
 ---
    @@ -209,6 +212,82 @@ case class EndsWith(left: Expression, right: 
Expression)
     }
     
     /**
    + * A function that returns the number of bytes in an expression
    + */
    +case class Length(child: Expression) extends UnaryExpression {
    +
    +  type EvaluatedType = Any
    +
    +  override def dataType = IntegerType
    +
    +  override def foldable = child.foldable
    +
    +  override def nullable = child.nullable
    +
    +  override def toString = s"Length($child)"
    +
    +  override def eval(input: Row): EvaluatedType = {
    +    val string = child.eval(input)
    +    if (string == null) {
    +      null
    +    } else if (!string.isInstanceOf[String]) {
    +      string.toString.length
    --- End diff --
    
    I don't know we should handle non-string types.
    In my opinion, we should handle only string type (and binary type the same 
as Hive?) and non-string type values should be casted or converted to string 
type before this.
    
    @marmbrus, what do you think about this?


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

Reply via email to