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

    https://github.com/apache/spark/pull/20135#discussion_r159234455
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringExpressions.scala
 ---
    @@ -271,33 +271,45 @@ case class ConcatWs(children: Seq[Expression])
       }
     }
     
    +/**
    + * An expression that returns the `n`-th input in given inputs.
    + * If all inputs are binary, `elt` returns an output as binary. Otherwise, 
it returns as string.
    + * If any input is null, `elt` returns null.
    + */
     // scalastyle:off line.size.limit
     @ExpressionDescription(
    -  usage = "_FUNC_(n, str1, str2, ...) - Returns the `n`-th string, e.g., 
returns `str2` when `n` is 2.",
    +  usage = "_FUNC_(n, input1, input2, ...) - Returns the `n`-th input, 
e.g., returns `input2` when `n` is 2.",
       examples = """
         Examples:
           > SELECT _FUNC_(1, 'scala', 'java');
            scala
       """)
     // scalastyle:on line.size.limit
    -case class Elt(children: Seq[Expression])
    -  extends Expression with ImplicitCastInputTypes {
    +case class Elt(children: Seq[Expression]) extends Expression {
     
       private lazy val indexExpr = children.head
    -  private lazy val stringExprs = children.tail.toArray
    +  private lazy val inputExprs = children.tail.toArray
     
       /** This expression is always nullable because it returns null if index 
is out of range. */
       override def nullable: Boolean = true
     
    -  override def dataType: DataType = StringType
    -
    -  override def inputTypes: Seq[DataType] = IntegerType +: 
Seq.fill(children.size - 1)(StringType)
    +  override def dataType: DataType = 
inputExprs.map(_.dataType).headOption.getOrElse(StringType)
    --- End diff --
    
    Should we return null of `BinaryType` when `eltOutputAsString` is `false` 
and there's only 1 parameter for `Elt`?


---

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

Reply via email to