morrySnow commented on code in PR #29617:
URL: https://github.com/apache/doris/pull/29617#discussion_r1443020256


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/window/Lead.java:
##########
@@ -90,9 +91,13 @@ public void checkLegalityBeforeTypeCoercion() {
             return;
         }
         if (children().size() >= 2) {
-            DataType offsetType = getOffset().getDataType();
-            if (!offsetType.isNumericType()) {
-                throw new AnalysisException("The offset of LEAD must be a 
number:" + this.toSql());
+            checkValidParams(child(1));
+            if (((Literal) getOffset()).getDouble() <= 0) {

Review Comment:
   checkValidParams not ensure param is literal, so there maybe throw cast 
error.



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/window/WindowFunction.java:
##########
@@ -46,11 +48,25 @@ public boolean equals(Object o) {
         }
         WindowFunction that = (WindowFunction) o;
         return Objects.equals(getName(), that.getName())
-            && Objects.equals(children, that.children);
+                && Objects.equals(children, that.children);
     }
 
     @Override
     public int hashCode() {
         return Objects.hash(getName(), children);
     }
+
+    /**
+     * LAG/LEAD param must be const number
+     */
+    public void checkValidParams(Expression param) {

Review Comment:
   protected is better



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/window/Lead.java:
##########
@@ -90,9 +91,13 @@ public void checkLegalityBeforeTypeCoercion() {
             return;
         }
         if (children().size() >= 2) {
-            DataType offsetType = getOffset().getDataType();
-            if (!offsetType.isNumericType()) {
-                throw new AnalysisException("The offset of LEAD must be a 
number:" + this.toSql());
+            checkValidParams(child(1));

Review Comment:
   it is better to call getOffset here



-- 
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-unsubscr...@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to