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

    https://github.com/apache/spark/pull/1359#discussion_r14801757
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringOperations.scala
 ---
    @@ -207,3 +207,71 @@ case class StartsWith(left: Expression, right: 
Expression) extends StringCompari
     case class EndsWith(left: Expression, right: Expression) extends 
StringComparison {
       def compare(l: String, r: String) = l.endsWith(r)
     }
    +
    +/**
    + * A function that takes a substring of its first argument starting at a 
given position.
    + * Defined for String and Binary types.
    + */
    +case class Substring(str: Expression, pos: Expression, len: Expression) 
extends Expression {
    +  
    +  type EvaluatedType = Any
    +  
    +  def nullable: Boolean = true
    +  def dataType: DataType = {
    +    if (!resolved) {
    +      throw new UnresolvedException(this, s"Cannot resolve since $children 
are not resolved")
    +    }
    +    if (str.dataType == BinaryType) str.dataType else StringType
    +  }
    +  
    +  def references = children.flatMap(_.references).toSet
    +  
    +  override def children = str :: pos :: len :: Nil
    +  
    +  @inline
    +  def slice[T, C <% IndexedSeqOptimized[T,_]](str: C, startPos: Int, 
sliceLen: Int): Any = {
    --- End diff --
    
    Would it be possible to do this without view bounds?  I think those are 
going to disappear soon: https://issues.scala-lang.org/browse/SI-7629


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