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 @@ -78,6 +78,10 @@ case class GenerateExec(
// boundGenerator.terminate() should be triggered after all of the rows in the partition
val numOutputRows = longMetric("numOutputRows")
child.execute().mapPartitionsWithIndexInternal { (index, iter) =>
boundGenerator.foreach {
case n: Nondeterministic => n.initialize(index)
case _ =>
}
val generatorNullRow = new GenericInternalRow(generator.elementSchema.length)
val rows = if (requiredChildOutput.nonEmpty) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,13 @@ class GeneratorFunctionSuite extends QueryTest with SharedSparkSession {
checkAnswer(df,
Row(1, 1) :: Row(1, 2) :: Row(2, 2) :: Row(2, 3) :: Row(3, null) :: Nil)
}

test("SPARK-45171: Handle evaluated nondeterministic expression") {
withSQLConf(SQLConf.WHOLESTAGE_CODEGEN_ENABLED.key -> "false") {
val df = sql("select explode(array(rand(0)))")
checkAnswer(df, Row(0.7604953758285915d))
}
}
}

case class EmptyGenerator() extends Generator with LeafLike[Expression] {
Expand Down