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

    https://github.com/apache/spark/pull/12364#discussion_r62167707
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/objects.scala
 ---
    @@ -688,3 +688,38 @@ case class AssertNotNull(child: Expression, 
walkedTypePath: Seq[String])
         ev.copy(code = code, isNull = "false", value = childGen.value)
       }
     }
    +
    +/**
    + * Returns the value of field at index `index` from the external row 
`child`.
    + *
    + * Note that the input row and the field we try to get are both guaranteed 
to be not null, if they
    + * are null, a runtime exception will be thrown.
    + */
    +case class GetExternalRowField(
    +    child: Expression,
    +    index: Int,
    +    dataType: DataType) extends UnaryExpression with NonSQLExpression {
    +
    +  override def nullable: Boolean = false
    +
    +  override def eval(input: InternalRow): Any =
    +    throw new UnsupportedOperationException("Only code-generated 
evaluation is supported")
    +
    +  override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = {
    +    val row = child.genCode(ctx)
    +
    +    val getField = dataType match {
    +      case ObjectType(x) if x == classOf[Row] => 
s"""${row.value}.getStruct($index)"""
    +      case _ => s"""(${ctx.boxedType(dataType)}) 
${row.value}.get($index)"""
    --- End diff --
    
    How about using `CodegenContext.getValue()` here to avoid boxing?


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