SEPURI-SAI-KRISHNA commented on code in PR #60175:
URL: https://github.com/apache/spark/pull/60175#discussion_r4511397455
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/window/WindowEvaluatorFactoryBase.scala:
##########
@@ -116,6 +116,20 @@ trait WindowEvaluatorFactoryBase {
val ordering = RowOrdering.create(orderSpec, childOutput)
RangeBoundOrdering(ordering, IdentityProjection, IdentityProjection)
+ case (RangeFrame, offset: Expression) if orderSpec.size == 1 &&
+ orderSpec.head.dataType.isInstanceOf[IntegralType] &&
+ offset.dataType.isInstanceOf[IntegralType] && offset.eval() != null
=>
Review Comment:
Thanks, confirmed. On this PR, `count(*) OVER (ORDER BY a RANGE BETWEEN
CAST(NULL AS BIGINT) PRECEDING AND CURRENT ROW)` on an `INT` column failed with
`scala.MatchError: (IntegerType,LongType)`, while Spark 4.0.3 returns rows with
a NULL bound.
Fixed in the latest commit: in the `Add` branch, a NULL integral offset of a
wider type is cast to the order type, as the coercion did before this PR, so
the bound is NULL as before. I kept that case on the existing path instead of
adding a NULL mode to `IntegralRangeBoundOrdering`, so NULL offsets run exactly
the code they ran before.
New test "range frames with a NULL integral offset of a wider type than the
order": `TINYINT`, `SMALLINT` and `INT` keys with a NULL `BIGINT` offset, alone
or with a non-NULL offset, in all four directions / null orderings, with ANSI
mode on and off, and with the segment tree and monotonic deque frames. It also
checks four frames against the rows Spark 4.0.3 returns. It fails with the
`MatchError` without the fix.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]