blueChild opened a new issue #5121:
URL: https://github.com/apache/incubator-doris/issues/5121


   **Describe the bug**
   
   In the 0.13.0-rc03 version, if there no partitions in the table, the 
following exception is reported when the COUNT() function is used:
   
   ```
   2020-12-22 15:52:35,871 WARN (doris-mysql-nio-pool-371|735) 
[StmtExecutor.analyze():466] Analyze failed because
   java.util.NoSuchElementException: No value present
           at java.util.Optional.get(Optional.java:135) ~[?:1.8.0_242]
           at 
org.apache.doris.catalog.OlapTable.getVisibleIndex(OlapTable.java:375) 
~[palo-fe.jar:?]
           at 
org.apache.doris.catalog.OlapTable.getVisibleIndexIdToMeta(OlapTable.java:367) 
~[palo-fe.jar:?]
           at 
org.apache.doris.catalog.OlapTable.getVisibleColumn(OlapTable.java:380) 
~[palo-fe.jar:?]
           at 
org.apache.doris.rewrite.mvrewrite.CountFieldToSum.apply(CountFieldToSum.java:77)
 ~[palo-fe.jar:?]
           at 
org.apache.doris.rewrite.ExprRewriter.applyRuleBottomUp(ExprRewriter.java:85) 
~[palo-fe.jar:?]
           at 
org.apache.doris.rewrite.ExprRewriter.applyRuleRepeatedly(ExprRewriter.java:71) 
~[palo-fe.jar:?]
           at 
org.apache.doris.rewrite.ExprRewriter.rewrite(ExprRewriter.java:55) 
~[palo-fe.jar:?]
           at 
org.apache.doris.analysis.QueryStmt.rewriteQueryExprByMvColumnExpr(QueryStmt.java:254)
 ~[palo-fe.jar:?]
           at org.apache.doris.analysis.SelectStmt.analyze(SelectStmt.java:369) 
~[palo-fe.jar:?]
           at 
org.apache.doris.qe.StmtExecutor.analyzeAndGenerateQueryPlan(StmtExecutor.java:484)
 ~[palo-fe.jar:?]
           at org.apache.doris.qe.StmtExecutor.analyze(StmtExecutor.java:454) 
~[palo-fe.jar:?]
           at org.apache.doris.qe.StmtExecutor.execute(StmtExecutor.java:242) 
~[palo-fe.jar:?]
           at 
org.apache.doris.qe.ConnectProcessor.handleQuery(ConnectProcessor.java:193) 
~[palo-fe.jar:?]
           at 
org.apache.doris.qe.ConnectProcessor.dispatch(ConnectProcessor.java:325) 
~[palo-fe.jar:?]
           at 
org.apache.doris.qe.ConnectProcessor.processOnce(ConnectProcessor.java:510) 
~[palo-fe.jar:?]
           at 
org.apache.doris.mysql.nio.ReadListener.lambda$handleEvent$0(ReadListener.java:50)
 ~[palo-fe.jar:?]
           at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) 
[?:1.8.0_242]
           at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) 
[?:1.8.0_242]
           at java.lang.Thread.run(Thread.java:748) [?:1.8.0_242]
   2020-12-22 15:52:35,871 WARN (doris-mysql-nio-pool-371|735) 
[StmtExecutor.execute():321] execute Exception. errCode = 2, detailMessage = 
Unexpected exception: No value present
   
   ```
   
   
   
   **To Reproduce**
   
   Steps to reproduce the behavior:
   
   1. create a table without partitions:
   
      ```mysql
      CREATE TABLE IF NOT EXISTS doris_app_event_record
      (pt_d INT NULL,app VARCHAR(256) NULL,
       event VARCHAR(256)  NULL,
       distribute_id VARCHAR(256)  NULL,
       bitmap_id BITMAP BITMAP_UNION NULL, 
       row_count INT  SUM NULL)
      PARTITION BY RANGE (pt_d) ( ) 
      DISTRIBUTED BY HASH(distribute_id) BUCKETS 3 
      PROPERTIES('replication_num' = '3');
      ```
   
      
   
   2. query the table with count() function:
   
      ```mysql
      mysql> SELECT pt_d FROM doris_app_event_record WHERE pt_d = 20201222;
      Empty set (0.00 sec)
      mysql> SELECT COUNT(*) FROM doris_app_event_record WHERE pt_d = 20201222;
      +----------+
      | count(*) |
      +----------+
      |        0 |
      +----------+
      1 row in set (0.00 sec)
      
      mysql> SELECT COUNT(pt_d) FROM doris_app_event_record WHERE pt_d = 
20201222;
      ERROR 1064 (HY000): errCode = 2, detailMessage = Unexpected exception: No 
value present
      
      ```
   
   
   
   **Expected behavior**
   
   I think the query results of count(pt_d) and count(*) should be the same, as 
in version 0.12.
   
   


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