xuzifu666 commented on code in PR #5178:
URL: https://github.com/apache/calcite/pull/5178#discussion_r3784572596


##########
core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java:
##########
@@ -2491,12 +2490,84 @@ protected FirstLastValueImplementor(SeekType seekType) {
         AggResultContext result) {
       WinAggResultContext winResult = (WinAggResultContext) result;
 
+      final boolean ignoreNulls =
+          info instanceof WinAggContext && ((WinAggContext) 
info).ignoreNulls();
+      if (ignoreNulls) {
+        return implementResultIgnoreNulls(info, winResult);
+      }
+
       return Expressions.condition(winResult.hasRows(),
           winResult.rowTranslator(
               winResult.computeIndex(Expressions.constant(0), seekType))
               .translate(winResult.rexArguments().get(0), info.returnType()),
           getDefaultValue(info.returnType()));
     }
+
+    /**
+     * Implements FIRST_VALUE / LAST_VALUE with IGNORE NULLS by scanning the
+     * frame (forward for FIRST_VALUE, backward for LAST_VALUE) and returning
+     * the first non-null argument value, or the default value if all rows in

Review Comment:
   You're right, the default value is always null here. I changed the Javadoc 
from "or the default value if all rows..." to "or null if all rows..." to be 
explicit.



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

Reply via email to