Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,12 @@ case class MapElementsExec(
}

override def doConsume(ctx: CodegenContext, input: Seq[ExprCode], row: ExprCode): String = {
val (funcClass, methodName) = func match {
val (funcClass, funcName) = func match {
case m: MapFunction[_, _] => classOf[MapFunction[_, _]] -> "call"
case _ => FunctionUtils.getFunctionOneName(outputObjectType, child.output(0).dataType)
}
val funcObj = Literal.create(func, ObjectType(funcClass))
val callFunc = Invoke(funcObj, methodName, outputObjectType, child.output)
val callFunc = Invoke(funcObj, funcName, outputObjectType, child.output, propagateNull = false)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the name methodName->funcName so as to put the code in a single line. plz let me know if I need to revert this.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks okay for that purpose.


val result = BindReferences.bindReference(callFunc, child.output).genCode(ctx)

Expand Down
10 changes: 10 additions & 0 deletions sql/core/src/test/scala/org/apache/spark/sql/DatasetSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1916,6 +1916,16 @@ class DatasetSuite extends QueryTest
assert(df1.semanticHash !== df3.semanticHash)
assert(df3.semanticHash === df4.semanticHash)
}

test("SPARK-31854: Invoke in MapElementsExec should not propagate null") {
Seq("true", "false").foreach { wholeStage =>
withSQLConf(SQLConf.WHOLESTAGE_CODEGEN_ENABLED.key -> wholeStage) {
val ds = Seq(1.asInstanceOf[Integer], null.asInstanceOf[Integer]).toDS()
val expectedAnswer = Seq[(Integer, Integer)]((1, 1), (null, null))
checkDataset(ds.map(v => (v, v)), expectedAnswer: _*)
}
}
}
}

object AssertExecutionId {
Expand Down