imay commented on a change in pull request #4732:
URL: https://github.com/apache/incubator-doris/pull/4732#discussion_r503876775



##########
File path: 
fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java
##########
@@ -334,11 +334,17 @@ private void analyzeBuiltinAggFunction(Analyzer analyzer) 
throws AnalysisExcepti
                 throw new AnalysisException(fnName.getFunction() + " only used 
in analytic function");
             } else {
                 if (children.size() > 2) {
-                    if (!getChild(2).isConstant()) {
+                    if (!getChild(1).isConstant() || 
!getChild(2).isConstant()) {
                         throw new AnalysisException(
                                 "The default parameter (parameter 3) of LAG 
must be a constant: "
                                         + this.toSql());
                     }
+                    getChild(1).type = Type.BIGINT;
+                    //To ensure that the correct function is selected,the 
third parameter
+                    //of the lead function must be consistent with the first 
parameter
+                    if (!getChild(2).type.matchesType(getChild(0).type) && 
!getChild(2).type.matchesType(Type.NULL)) {
+                        getChild(2).type = getChild(0).type;
+                    }

Review comment:
       You should call uncheckCastTo to change child's type.

##########
File path: 
fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java
##########
@@ -334,11 +334,17 @@ private void analyzeBuiltinAggFunction(Analyzer analyzer) 
throws AnalysisExcepti
                 throw new AnalysisException(fnName.getFunction() + " only used 
in analytic function");
             } else {
                 if (children.size() > 2) {
-                    if (!getChild(2).isConstant()) {
+                    if (!getChild(1).isConstant() || 
!getChild(2).isConstant()) {

Review comment:
       Should change the warning log




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

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