yashmayya commented on code in PR #14264:
URL: https://github.com/apache/pinot/pull/14264#discussion_r1818944382


##########
pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/NullHandlingIntegrationTest.java:
##########
@@ -326,6 +326,31 @@ public void testAggregateServerReturnFinalResult(boolean 
useMultiStageQueryEngin
     assertTrue(response.get("resultTable").get("rows").get(0).get(0).isNull());
   }
 
+  @Test
+  public void testWindowFunctionIgnoreNulls()
+      throws Exception {
+    // Window functions are only supported in the multi-stage query engine
+    setUseMultiStageQueryEngine(true);
+    String sqlQuery =
+        "SELECT salary, LAST_VALUE(salary) IGNORE NULLS OVER (ORDER BY 
DaysSinceEpoch) AS gapfilledSalary from "

Review Comment:
   Yes, actually this does look like a legitimate bug in Calcite on taking a 
second look. The issue is that the inferred return type for the window function 
in the parsed `SqlNode` is `INTEGER NOT NULL` when `IGNORE NULLS` option is 
used (assuming the column input to `FIRST_VALUE` / `LAST_VALUE` is `INTEGER`) 
and the converted return type is `INTEGER` (nullable) because offset based 
window frame bounds means that the result can be `null` when the window frame 
is out of bounds - which can't be the case when using `RANGE` window frames or 
`ROWS` window frames with `UNBOUNDED PRECEDING` / `UNBOUNDED FOLLOWING` / 
`CURRENT ROW`. When `IGNORE NULLS` option is not provided, the inferred return 
type for the window function in the parsed `SqlNode` is also `INTEGER` 
(nullable) which is why the issue doesn't occur there. Same when `IGNORE NULLS` 
option is used but input column is nullable. 
   
   Interestingly, the same error and issue also occurs when the `RESPECT NULLS` 
option is explicitly provided.
   
   I'll create a  bug tracking Jira in the Calcite project and link it here.
   
   Edit: https://issues.apache.org/jira/browse/CALCITE-6648



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