LuciferYang commented on code in PR #55422:
URL: https://github.com/apache/spark/pull/55422#discussion_r3122403981


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/window/WindowEvaluatorFactoryBase.scala:
##########
@@ -295,4 +342,58 @@ trait WindowEvaluatorFactoryBase {
     }
   }
 
+  /**
+   * Segment-tree path eligibility. The tree relies on
+   * `DeclarativeAggregate.mergeExpressions`, which 
[[AggregateWindowFunction]]s
+   * (NthValue, NTile, Rank, RowNumber, NullIndex) refuse via
+   * `mergeUnsupportedByWindowFunctionError`: they extend DeclarativeAggregate
+   * but are NOT merge-capable. Normal aggregate window expressions reach this
+   * code as the inner DeclarativeAggregate unwrapped from
+   * [[AggregateExpression]] (see `windowFrameExpressionFactoryPairs.collect`).
+   */
+  private def eligibleForSegTree(
+      functions: Array[Expression],
+      filters: Array[Option[Expression]],
+      frameType: FrameType): Boolean = {
+    // RANGE accepted only for single-column order specs. Multi-column RANGE
+    // with non-zero offset is already rejected by `createBoundOrdering`, so
+    // gating here on `orderSpec.size == 1` matches the Sliding-path invariant.
+    val frameTypeOk = frameType match {
+      case RowFrame => true
+      case RangeFrame => orderSpec.size == 1

Review Comment:
   1. Add explicit cases for ties at the endpoint (RANGE includes all rows with 
equal order-key), block-boundary frames at multiple `blockSize` values, and 
empty frames produced by RANGE semantics.
     2. Parameterize `WindowSegmentTreePropertySuite` over `FrameType` so 
random-shape generators exercise both `Row` and `Range`.
     3. `estimateMaxCachedBlocks` returns `Some(8)` for `RangeFrame`. At `W >> 
8 ยท blockSize` this thrashes the LRU and triggers repeated `buildBlockLevels`. 
May need add a benchmark case at the thrash boundary and either raise the 
default or compute it from observed endpoint span.



-- 
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]

Reply via email to