kgyrtkirk commented on code in PR #16301:
URL: https://github.com/apache/druid/pull/16301#discussion_r1570413882


##########
sql/src/main/java/org/apache/druid/sql/calcite/rel/Windowing.java:
##########
@@ -243,8 +244,14 @@ public static Windowing fromCalciteStuff(
       // We know windowProject is a mapping due to the isMapping() check in 
DruidRules. Check for null anyway,
       // as defensive programming.
       final Mappings.TargetMapping mapping = Preconditions.checkNotNull(
-          partialQuery.getWindowProject().getMapping(),
-          "mapping for windowProject[%s]", partialQuery.getWindowProject()
+              
partialQuery.getWindowProject().getProjects().stream().map(RexNode::toString).collect(Collectors.toSet()).size()
+                      < partialQuery.getWindowProject().getProjects().size()
+                      ? Project.getPartialMapping(
+                              
partialQuery.getWindowProject().getRowType().getFieldCount(),
+                              partialQuery.getWindowProject().getProjects()
+                      )
+                      : partialQuery.getWindowProject().getMapping(),
+              "mapping for windowProject[%s]", partialQuery.getWindowProject()

Review Comment:
   discussed offline; but leave a note here:
   I believe we want a real `PartialMapping`  ; you could copy 
`getPartialMapping` over and change 
   `INVERSE_FUNCTION` to `INVERSE_PARTIAL_FUNCTION`
   
   that way we will support partial mapping even in case columns are being 
discarded...
   
   I also think that `Project.getPartialMapping` might need this change as its 
apidoc suggersts that [a source might have 0, 1 or more 
targets.](https://github.com/apache/calcite/blob/b4bcd3b69a39ac40974690d1bd4ea08f364638ce/core/src/main/java/org/apache/calcite/rel/core/Project.java#L420)



##########
sql/src/test/java/org/apache/druid/sql/calcite/CalciteWindowQueryTest.java:
##########
@@ -231,6 +233,25 @@ public void 
windowQueryTestWithCustomContextMaxSubqueryBytes(String filename) th
     }
   }
 
+  @Test
+  public void testWindow()
+  {
+    testBuilder()
+            .sql("SELECT\n" +

Review Comment:
   great idea :)
   after the separation of test suppliers 
[patch](https://github.com/apache/druid/pull/16275) gets in that we'll be even 
easier to do!



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