akupchinskiy commented on code in PR #7813:
URL: https://github.com/apache/datafusion-comet/pull/7813#discussion_r4771643012
##########
spark/src/main/scala/org/apache/spark/sql/comet/CometWindowExec.scala:
##########
@@ -545,6 +581,29 @@ object CometWindowExec extends
CometOperatorSerde[WindowExec] {
case _ =>
}
+ // Spark accepts a frame whose lower bound lies after its upper bound when
one of them is
+ // CURRENT ROW, such as `2 FOLLOWING AND CURRENT ROW`, and evaluates every
frame as empty.
+ // DataFusion computes a range whose start is past its end for it, and its
sliding
+ // accumulator fails on that range. A NaN RANGE offset gives a bound Spark
compares as the
+ // largest value, so a NaN lower bound also makes every frame empty, while
the native frame
+ // computes a NaN bound and reaches the same reversed range.
+ f match {
+ case SpecifiedWindowFrame(_, lb, ub) if Seq(lb, ub).exists(isNaNBound) =>
+ withFallbackReason(
+ windowExpr,
+ s"Window frame with a NaN offset is not supported: ${lb.sql} AND
${ub.sql}")
+ return None
+ case SpecifiedWindowFrame(_, lb, ub)
+ if (ub == CurrentRow && boundSignum(lb) > 0) ||
+ (lb == CurrentRow && boundSignum(ub) < 0) =>
+ withFallbackReason(
+ windowExpr,
+ "Window frame with a lower bound after its upper bound is not
supported: " +
+ s"${lb.sql} AND ${ub.sql}")
Review Comment:
Good catch, it would have printed -2. The reason now reads like `ROWS frame
with lower bound CURRENT ROW after upper bound 2 PRECEDING is not supported`.
##########
spark/src/test/scala/org/apache/comet/exec/CometWindowExecSuite.scala:
##########
@@ -492,6 +492,75 @@ class CometWindowExecSuite extends CometTestBase {
}
}
+ test("window: frame with a lower bound after its upper bound falls back") {
Review Comment:
Moved it to `sql-tests/windows/reversed_frame.sql` and added DESC and NULL
keys there. It needs `ConstantFolding: enabled`, since Spark only takes a
folded literal as a ROWS offset.
--
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]