qidaye opened a new issue #7509: URL: https://github.com/apache/incubator-doris/issues/7509
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/incubator-doris/issues?q=is%3Aissue) and found no similar issues. ### Version 3454735eba285d8422ce36bf102612995e2ed63e ### What's Wrong? When enable fold constant by BE, the constant expr in order by clause will go wrong. ### What You Expected? Work normal when enable fold constant function. ### How to Reproduce? 1. Create a table ```sql CREATE TABLE `t1` ( `k1` int(11) NULL DEFAULT "0" COMMENT "唯一ID", `k2` int(11) NULL DEFAULT "0" COMMENT "" ) ENGINE=OLAP DUPLICATE KEY(`k1`, `k2`) COMMENT "OLAP" DISTRIBUTED BY HASH(`k1`) BUCKETS 1 PROPERTIES ( "replication_allocation" = "tag.location.default: 1", "in_memory" = "false", "storage_format" = "V2" ); ``` 2. Execute sql ```sql select * from t1 order by now(); ``` 3. Throw null pointer exception ```sql mysql> select * from t1 order by now(); ERROR 1105 (HY000): errCode = 2, detailMessage = Unexpected exception: null ``` ### Anything Else? Error message in `fe.log`. ``` 2021-12-28 15:04:23,922 WARN (doris-mysql-nio-pool-7|203) [StmtExecutor.analyze():571] Analyze failed because java.lang.IllegalStateException: null at com.google.common.base.Preconditions.checkState(Preconditions.java:492) ~[spark-dpp-1.0.0.jar:1.0.0] at org.apache.doris.analysis.FunctionCallExpr.isAggregateFunction(FunctionCallExpr.java:288) ~[palo-fe.jar:3.4.0] at org.apache.doris.analysis.Expr$1.apply(Expr.java:79) ~[palo-fe.jar:3.4.0] at org.apache.doris.analysis.Expr$1.apply(Expr.java:76) ~[palo-fe.jar:3.4.0] at org.apache.doris.analysis.Expr.isAggregate(Expr.java:957) ~[palo-fe.jar:3.4.0] at org.apache.doris.analysis.FunctionCallExpr.toThrift(FunctionCallExpr.java:350) ~[palo-fe.jar:3.4.0] at org.apache.doris.analysis.Expr.treeToThriftHelper(Expr.java:922) ~[palo-fe.jar:3.4.0] at org.apache.doris.analysis.Expr.treeToThrift(Expr.java:901) ~[palo-fe.jar:3.4.0] at org.apache.doris.rewrite.FoldConstantsRule.getConstExpr(FoldConstantsRule.java:218) ~[palo-fe.jar:3.4.0] at org.apache.doris.rewrite.FoldConstantsRule.apply(FoldConstantsRule.java:147) ~[palo-fe.jar:3.4.0] at org.apache.doris.rewrite.ExprRewriter.rewriteConstant(ExprRewriter.java:105) ~[palo-fe.jar:3.4.0] at org.apache.doris.analysis.QueryStmt.foldConstant(QueryStmt.java:470) ~[palo-fe.jar:3.4.0] at org.apache.doris.qe.StmtExecutor.analyzeAndGenerateQueryPlan(StmtExecutor.java:630) ~[palo-fe.jar:3.4.0] at org.apache.doris.qe.StmtExecutor.analyze(StmtExecutor.java:559) ~[palo-fe.jar:3.4.0] at org.apache.doris.qe.StmtExecutor.execute(StmtExecutor.java:326) ~[palo-fe.jar:3.4.0] at org.apache.doris.qe.StmtExecutor.execute(StmtExecutor.java:299) ~[palo-fe.jar:3.4.0] at org.apache.doris.qe.ConnectProcessor.handleQuery(ConnectProcessor.java:212) ~[palo-fe.jar:3.4.0] at org.apache.doris.qe.ConnectProcessor.dispatch(ConnectProcessor.java:349) ~[palo-fe.jar:3.4.0] at org.apache.doris.qe.ConnectProcessor.processOnce(ConnectProcessor.java:551) ~[palo-fe.jar:3.4.0] at org.apache.doris.mysql.nio.ReadListener.lambda$handleEvent$0(ReadListener.java:50) ~[palo-fe.jar:3.4.0] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_131] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_131] at java.lang.Thread.run(Thread.java:748) [?:1.8.0_131] 2021-12-28 15:04:23,929 WARN (doris-mysql-nio-pool-7|203) [StmtExecutor.execute():439] execute Exception. errCode = 2, detailMessage = Unexpected exception: null ``` This bug is similar to #7478 ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct) -- 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]
