You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by "ankitsultana (via GitHub)" <gi...@apache.org> on 2023/04/18 23:23:19 UTC

[GitHub] [pinot] ankitsultana commented on a diff in pull request #10635: [multistage] Modify empty LogicalProject for window functions to have a literal

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


##########
pinot-query-planner/src/main/java/org/apache/calcite/rel/rules/PinotWindowExchangeNodeInsertRule.java:
##########
@@ -171,4 +195,55 @@ private boolean isPartitionByOnlyQuery(Window.Group windowGroup) {
     }
     return isPartitionByOnly;
   }
+
+  /**
+   * Only empty OVER() type queries can result in a situation where the LogicalProject below the LogicalWindow is an
+   * empty LogicalProject (i.e. no columns are projected). This can only occur for window functions that don't take
+   * an input column. Some example queries where this can occur are:
+   *
+   * SELECT COUNT(*) OVER() from tableName
+   * SELECT 42, COUNT(*) OVER() from tableName
+   * SELECT ROW_NUMBER() OVER() from tableName
+   *
+   * This function modifies the empty LogicalProject below the LogicalWindow to add a literal and adds a LogicalProject
+   * above LogicalWindow to remove the additional literal column from being projected any further. This also handles
+   * the addition of the LogicalExchange under the LogicalWindow.
+   */
+  private RelNode handleEmptyProjectBelowWindow(Window window, Project project) {
+    RelOptCluster cluster = window.getCluster();
+    RexBuilder rexBuilder = cluster.getRexBuilder();
+
+    // Construct the project that goes below the window (which projects a literal)
+    final List<RexNode> expsForProjectBelowWindow = Collections.singletonList(
+        rexBuilder.makeLiteral(0, cluster.getTypeFactory().createSqlType(SqlTypeName.INTEGER)));

Review Comment:
   Windows also have a "constant" concept which seem to be "additional inputs". Do you know where they are supposed to be used?



##########
pinot-query-planner/src/main/java/org/apache/calcite/rel/rules/PinotWindowExchangeNodeInsertRule.java:
##########
@@ -171,4 +195,55 @@ private boolean isPartitionByOnlyQuery(Window.Group windowGroup) {
     }
     return isPartitionByOnly;
   }
+
+  /**

Review Comment:
   Can you leave a TODO for support for column-less tuples?



-- 
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-unsubscribe@pinot.apache.org

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


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