Jackie-Jiang commented on code in PR #14233:
URL: https://github.com/apache/pinot/pull/14233#discussion_r1802470255


##########
pinot-query-planner/src/main/java/org/apache/pinot/calcite/rel/rules/PinotWindowExchangeNodeInsertRule.java:
##########
@@ -209,23 +244,37 @@ private void validateWindows(Window window) {
   }
 
   private void validateWindowAggCallsSupported(Window.Group windowGroup) {
-    for (int i = 0; i < windowGroup.aggCalls.size(); i++) {
-      Window.RexWinAggCall aggCall = windowGroup.aggCalls.get(i);
+    for (Window.RexWinAggCall aggCall : windowGroup.aggCalls) {
       SqlKind aggKind = aggCall.getKind();
       
Preconditions.checkState(SUPPORTED_WINDOW_FUNCTION_KIND.contains(aggKind),
           String.format("Unsupported Window function kind: %s. Only 
aggregation functions are supported!", aggKind));
     }
   }
 
   private void validateWindowFrames(Window.Group windowGroup) {
-    // Has ROWS only aggregation call kind (e.g. ROW_NUMBER)?
-    boolean isRowsOnlyTypeAggregateCall = 
isRowsOnlyAggregationCallType(windowGroup.aggCalls);
+    // Has rank based aggregation call kind (e.g. ROW_NUMBER, RANK, DENSE_RANK)
+    boolean hasRankBasedAgg = hasRankBasedAgg(windowGroup.aggCalls);
+
+    // FOLLOWING lower bound or PRECEDING upper bound is not allowed, and 
won't reach here
+    RexWindowBound lowerBound = windowGroup.lowerBound;
+    assert !lowerBound.isFollowing();
+    RexWindowBound upperBound = windowGroup.upperBound;
+    assert !upperBound.isPreceding();
+    boolean hasBound = (lowerBound.isPreceding() && !lowerBound.isUnbounded()) 
|| (upperBound.isFollowing()
+        && !upperBound.isUnbounded());
+
+    if (hasRankBasedAgg) {
+      Preconditions.checkState(!hasBound, "Window frame is not supported for 
ROW_NUMBER, RANK, DENSE_RANK functions");
+    }
+    if (!windowGroup.isRows) {
+      Preconditions.checkState(!hasBound, "Bounded RANGE window frame is 
currently not supported");
+    }
     // For Phase 1 only the default frame is supported
-    Preconditions.checkState(!windowGroup.isRows || 
isRowsOnlyTypeAggregateCall,
+    Preconditions.checkState(!windowGroup.isRows || hasRankBasedAgg,

Review Comment:
   Line 272-283 was supposed to be removed. I accidentally reverted the removal 
to compare with the new logic



-- 
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: commits-unsubscr...@pinot.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to