From b653ce23d1ea27ce357185e4708f0e57ea14d772 Mon Sep 17 00:00:00 2001 From: Liangcai Li Date: Mon, 28 Oct 2024 10:38:19 +0800 Subject: [PATCH] Fix a NPE issue in GpuRand (#11647) curXORShiftRandomSeed is marked as transient, so it will be null on executors without retry-restore context, leading to this NPE. This fix removes the transient for curXORShiftRandomSeed, seed and previousPartition that will be used by the computation on executors. Signed-off-by: Firestarman --- .../rapids/catalyst/expressions/GpuRandomExpressions.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sql-plugin/src/main/scala/org/apache/spark/sql/rapids/catalyst/expressions/GpuRandomExpressions.scala b/sql-plugin/src/main/scala/org/apache/spark/sql/rapids/catalyst/expressions/GpuRandomExpressions.scala index f9d0be81505..efc59749d2d 100644 --- a/sql-plugin/src/main/scala/org/apache/spark/sql/rapids/catalyst/expressions/GpuRandomExpressions.scala +++ b/sql-plugin/src/main/scala/org/apache/spark/sql/rapids/catalyst/expressions/GpuRandomExpressions.scala @@ -49,16 +49,16 @@ case class GpuRand(child: Expression) extends ShimUnaryExpression with GpuExpres */ @transient protected var rng: RapidsXORShiftRandom = _ - @transient protected lazy val seed: Long = child match { + private lazy val seed: Long = child match { case GpuLiteral(s, IntegerType) => s.asInstanceOf[Int] case GpuLiteral(s, LongType) => s.asInstanceOf[Long] case _ => throw new RapidsAnalysisException( s"Input argument to $prettyName must be an integer, long or null literal.") } - @transient protected var previousPartition: Int = 0 + private var previousPartition: Int = 0 - @transient protected var curXORShiftRandomSeed: Option[Long] = None + private var curXORShiftRandomSeed: Option[Long] = None private def wasInitialized: Boolean = rng != null