ankitsultana commented on code in PR #15958:
URL: https://github.com/apache/pinot/pull/15958#discussion_r2140651234


##########
pinot-query-planner/src/main/java/org/apache/pinot/calcite/rel/rules/PinotRuleUtils.java:
##########
@@ -122,4 +135,129 @@ public static String extractFunctionName(RexCall 
function) {
     SqlKind funcSqlKind = function.getOperator().getKind();
     return funcSqlKind == SqlKind.OTHER_FUNCTION ? 
function.getOperator().getName() : funcSqlKind.name();
   }
+
+  public static class WindowUtils {
+    // Supported window functions
+    // OTHER_FUNCTION supported are: BOOL_AND, BOOL_OR
+    private static final EnumSet<SqlKind> SUPPORTED_WINDOW_FUNCTION_KIND =
+        EnumSet.of(SqlKind.SUM, SqlKind.SUM0, SqlKind.MIN, SqlKind.MAX, 
SqlKind.COUNT, SqlKind.ROW_NUMBER, SqlKind.RANK,
+            SqlKind.DENSE_RANK, SqlKind.NTILE, SqlKind.LAG, SqlKind.LEAD, 
SqlKind.FIRST_VALUE, SqlKind.LAST_VALUE,
+            SqlKind.OTHER_FUNCTION);
+
+    public static void validateWindows(Window window) {
+      int numGroups = window.groups.size();
+      // For Phase 1 we only handle single window groups
+      Preconditions.checkState(numGroups == 1,
+          String.format("Currently only 1 window group is supported, query has 
%d groups", numGroups));
+
+      // Validate that only supported window aggregation functions are present
+      Window.Group windowGroup = window.groups.get(0);
+      validateWindowAggCallsSupported(windowGroup);
+
+      // Validate the frame
+      validateWindowFrames(windowGroup);
+    }
+
+    /**
+     * Replaces the reference to literal arguments in the window group with 
the actual literal values.
+     * NOTE: {@link Window} has a field called "constants" which contains the 
literal values. If the input reference is
+     * beyond the window input size, it is a reference to the constants.
+     */
+    public static Window.Group updateLiteralArgumentsInWindowGroup(Window 
window) {

Review Comment:
   This is lifted as is from `PinotWindowExchangeNodeInsertRule`. GPT response 
is largely right: rex input ref is an integer reference to the input, but in 
window group it could exceed the field count of the input, in which case it is 
actually a reference to window.constants.



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