dongjoon-hyun commented on code in PR #55422:
URL: https://github.com/apache/spark/pull/55422#discussion_r3148825366
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/window/AggregateProcessor.scala:
##########
@@ -181,7 +181,26 @@ private[window] final class AggregateProcessor(
}
/** Evaluate buffer. */
- def evaluate(target: InternalRow): Unit = {
- evaluateProjection.target(target)(buffer)
+ def evaluate(target: InternalRow): Unit = evaluate(buffer, target)
+
+ /**
+ * Evaluate using an arbitrary `source` buffer (e.g. a segment-tree query
+ * result) instead of the internal one.
+ *
+ * '''Contract''': `source` must share this processor's internal
+ * `aggBufferAttributes` layout -- same field count, same dataTypes, in the
+ * same order. The segment-tree path enforces this upstream in
+ * `WindowEvaluatorFactoryBase.eligibleForSegTree` (rejects
+ * `SizeBasedWindowFunction`; the same `functions:
Array[DeclarativeAggregate]`
Review Comment:
Since this PR uses a while-list like the following currently, we had better
mention it instead of `SizeBasedWindowFunction` here. If we want to mention
`SizeBasedWindowFunction`, it should be mentioned in `def isEligible` or `val
EligibleAggregates`.
```scala
val EligibleAggregates: Set[Class[_ <: DeclarativeAggregate]] = Set(
classOf[Min],
classOf[Max],
classOf[Sum],
classOf[Count],
classOf[Average],
classOf[StddevPop],
classOf[StddevSamp],
classOf[VariancePop],
classOf[VarianceSamp]
)
/**
* Returns true iff `f` is a [[DeclarativeAggregate]] on the explicit
segment-tree
* allowlist. See [[EligibleAggregates]] for the rationale and excluded
aggregates.
*/
def isEligible(f: Expression): Boolean = f match {
case agg: DeclarativeAggregate =>
EligibleAggregates.contains(agg.getClass)
case _ => false
}
```
--
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]