beliefer commented on code in PR #50552: URL: https://github.com/apache/spark/pull/50552#discussion_r2055423794
########## sql/core/src/main/scala/org/apache/spark/sql/execution/window/WindowFunctionFrame.scala: ########## @@ -180,10 +180,20 @@ abstract class OffsetWindowFunctionFrameBase( } } + /** Indicates whether the default values are Literal values. */ + protected lazy val onlyLiteralNulls = expressions.forall { e => + e.default == null || (e.default.foldable && e.default.eval() == null) + } override def prepare(rows: ExternalAppendOnlyUnsafeRowArray): Unit = { resetStates(rows) if (absOffset > rows.length) { - fillDefaultValue(EmptyRow) + // Avoid evaluating non-literal defaults with EmptyRow, + // which causes NullPointerException. + // Check whether defaults are Literal or null. + if (onlyLiteralNulls) { Review Comment: I think we should apply `fillDefaultValue` for any foldable expression here, not only the null literal. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org