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

    https://github.com/apache/spark/pull/20771#discussion_r173364839
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/objects/objects.scala
 ---
    @@ -501,12 +502,22 @@ case class LambdaVariable(
         value: String,
         isNull: String,
         dataType: DataType,
    -    nullable: Boolean = true) extends LeafExpression
    -  with Unevaluable with NonSQLExpression {
    +    nullable: Boolean = true) extends LeafExpression with NonSQLExpression 
{
    +
    +  // Interpreted execution of `LambdaVariable` always get the 0-index 
element from input row.
    +  override def eval(input: InternalRow): Any = {
    +    assert(input.numFields == 1,
    +      "The input row of interpreted LambdaVariable should have only 1 
field.")
    +    input.get(0, dataType)
    --- End diff --
    
    You mean like this?
    ```scala
    lazy val accessor:  InternalRow => Any = dataType match {
      case IntegerType => (inputRow) => inputRow.getInt(0)
      case LongType => (inputRow) => inputRow.getLong(0)
      ...
    }
    
    override def eval(input: InternalRow): Any = accessor(input)
    ```


---

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

Reply via email to