in backends-velox/src/main/scala/io/glutenproject/backendsapi/velox/VeloxBackend.scala [219:287]
override def supportWindowExec(windowFunctions: Seq[NamedExpression]): Boolean = {
var allSupported = true
breakable {
windowFunctions.foreach(
func => {
val windowExpression = func match {
case alias: Alias => WindowFunctionsBuilder.extractWindowExpression(alias.child)
case _ => throw new UnsupportedOperationException(s"$func is not supported.")
}
// Block the offloading by checking Velox's current limitations
// when literal bound type is used for RangeFrame.
def checkLimitations(swf: SpecifiedWindowFrame, orderSpec: Seq[SortOrder]): Unit = {
def doCheck(bound: Expression, isUpperBound: Boolean): Unit = {
bound match {
case _: SpecialFrameBoundary =>
case e if e.foldable =>
orderSpec.foreach(
order =>
order.direction match {
case Descending =>
throw new UnsupportedOperationException(
"DESC order is not supported when" +
" literal bound type is used!")
case _ =>
})
orderSpec.foreach(
order =>
order.dataType match {
case ByteType | ShortType | IntegerType | LongType | DateType =>
case _ =>
throw new UnsupportedOperationException(
"Only integral type & date type are" +
" supported for sort key when literal bound type is used!")
})
val rawValue = e.eval().toString.toLong
if (isUpperBound && rawValue < 0) {
throw new UnsupportedOperationException(
"Negative upper bound is not supported!")
} else if (!isUpperBound && rawValue > 0) {
throw new UnsupportedOperationException(
"Positive lower bound is not supported!")
}
case _ =>
}
}
doCheck(swf.upper, true)
doCheck(swf.lower, false)
}
windowExpression.windowSpec.frameSpecification match {
case swf: SpecifiedWindowFrame =>
swf.frameType match {
case RangeFrame =>
checkLimitations(swf, windowExpression.windowSpec.orderSpec)
case _ =>
}
case _ =>
}
windowExpression.windowFunction match {
case _: RowNumber | _: AggregateExpression | _: Rank | _: CumeDist | _: DenseRank |
_: PercentRank | _: NthValue =>
case _ =>
allSupported = false
}
})
}
allSupported
}