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 @@ -217,7 +217,8 @@ case class MapElementsExec(
case _ => FunctionUtils.getFunctionOneName(outputObjAttr.dataType, child.output(0).dataType)
}
val funcObj = Literal.create(func, ObjectType(funcClass))
val callFunc = Invoke(funcObj, methodName, outputObjAttr.dataType, child.output)
val callFunc = Invoke(funcObj, methodName, outputObjAttr.dataType, child.output,
propagateNull = false)

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 @@ -1576,6 +1576,16 @@ class DatasetSuite extends QueryTest with SharedSQLContext {
}
assert(thrownException.message.contains("Cannot up cast `id` from bigint to tinyint"))
}

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: _*)
}
}
}
}

case class TestDataUnion(x: Int, y: Int, z: Int)
Expand Down