WangGuangxin commented on code in PR #5626:
URL: https://github.com/apache/incubator-gluten/pull/5626#discussion_r1626763144


##########
gluten-core/src/main/scala/org/apache/gluten/utils/PullOutProjectHelper.scala:
##########
@@ -143,8 +144,39 @@ trait PullOutProjectHelper {
     ae.copy(aggregateFunction = newAggFunc, filter = newFilter)
   }
 
+  private def needPreComputeRangeFrameBoundary(bound: Expression): Boolean = {
+    bound match {
+      case _: PreComputeRangeFrameBound => false
+      case _ if !bound.foldable => false
+      case _ => true
+    }
+  }
+
+  private def preComputeRangeFrameBoundary(
+      bound: Expression,
+      orderSpec: SortOrder,
+      expressionMap: mutable.HashMap[Expression, NamedExpression]): Expression 
= {
+    bound match {
+      case _: PreComputeRangeFrameBound => bound
+      case _ if !bound.foldable => bound
+      case _ if bound.foldable =>
+        val a = expressionMap
+          .getOrElseUpdate(
+            bound.canonicalized,
+            Alias(Add(orderSpec.child, bound), generatePreAliasName)())

Review Comment:
   > Do we really support reuse the reference for the same bound literal ? What 
happens if the two window expressions have the same frame but requires 
different ordering column.
   > 
   > ```
   >   sum(x) OVER (
   >     PARTITION BY c1
   >     ORDER BY c2 RANGE BETWEEN 1 preceding AND CURRENT ROW
   >   ), 
   >   sum(x) OVER (
   >     PARTITION BY c1
   >     ORDER BY c3 RANGE BETWEEN 1 preceding AND CURRENT ROW
   >   )
   > ```
   
   let me check



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