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


##########
pinot-query-planner/src/main/java/org/apache/calcite/rel/rules/PinotWindowExchangeNodeInsertRule.java:
##########
@@ -171,4 +196,58 @@ 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 = new ArrayList<>();
+    final RelDataTypeFactory.Builder builder = 
cluster.getTypeFactory().builder();

Review Comment:
   good point, fixed!



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