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 @@ -42,4 +42,11 @@ trait ExpressionsEvaluator {
* The default implementation does nothing.
*/
def initialize(partitionIndex: Int): Unit = {}

protected def initializeExprs(exprs: Seq[Expression], partitionIndex: Int): Unit = {
exprs.foreach(_.foreach {
case n: Nondeterministic => n.initialize(partitionIndex)
case _ =>
})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ class InterpretedMutableProjection(expressions: Seq[Expression]) extends Mutable
private[this] val buffer = new Array[Any](expressions.size)

override def initialize(partitionIndex: Int): Unit = {
exprs.foreach(_.foreach {
case n: Nondeterministic => n.initialize(partitionIndex)
case _ =>
})
initializeExprs(exprs, partitionIndex)
}

private[this] val validExprs = expressions.zipWithIndex.filter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,7 @@ class InterpretedSafeProjection(expressions: Seq[Expression]) extends Projection
}

override def initialize(partitionIndex: Int): Unit = {
expressions.foreach(_.foreach {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this was a mistake in #39248 . We should initialize the final exprs, not expressions

case n: Nondeterministic => n.initialize(partitionIndex)
case _ =>
})
initializeExprs(exprs, partitionIndex)
}

override def apply(row: InternalRow): InternalRow = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,7 @@ class InterpretedUnsafeProjection(expressions: Array[Expression]) extends Unsafe
}

override def initialize(partitionIndex: Int): Unit = {
exprs.foreach(_.foreach {
case n: Nondeterministic => n.initialize(partitionIndex)
case _ =>
})
initializeExprs(exprs, partitionIndex)
}

override def apply(row: InternalRow): UnsafeRow = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ class InterpretedProjection(expressions: Seq[Expression]) extends Projection {
}

override def initialize(partitionIndex: Int): Unit = {
exprArray.foreach(_.foreach {
case n: Nondeterministic => n.initialize(partitionIndex)
case _ =>
})
initializeExprs(exprArray, partitionIndex)
}

def apply(input: InternalRow): InternalRow = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,7 @@ case class InterpretedPredicate(expression: Expression) extends BasePredicate {
}

override def initialize(partitionIndex: Int): Unit = {
super.initialize(partitionIndex)
expr.foreach {
case n: Nondeterministic => n.initialize(partitionIndex)
case _ =>
}
initializeExprs(Seq(expr), partitionIndex)
}
}

Expand Down