horus-leonardo opened a new issue, #52327:
URL: https://github.com/apache/doris/issues/52327

   ### Search before asking
   
   - [x] I had searched in the 
[issues](https://github.com/apache/doris/issues?q=is%3Aissue) and found no 
similar issues.
   
   
   ### Version
   
   2.1.9
   
   ### What's Wrong?
   
   When executing a query with CASE WHEN clause that checks IS NOT NULL on a 
date column before performing date arithmetic (first_date - second_date), the 
Nereids optimizer times out after 31 seconds, exceeding the 30-second limit. 
The query fails with error:
   `SQL [1105] [HY000]: errCode = 2, detailMessage = Nereids cost too much time 
( 31s > 30s`
   
   This appears to be a specific edge case where the combination of CASE WHEN 
[date_column] IS NOT NULL with date arithmetic causes the optimizer to hang, 
even though the CASE WHEN logic is redundant in this context since AVG() 
already handles NULL values correctly.
   
   ### What You Expected?
   
   NULL result
   
   ### How to Reproduce?
   
   Create a simple table with two date columns:
   `CREATE TABLE example_dataset
   (
       first_date DATE,
       second_date DATE
   );`
   
   Execute the following query:
   `SELECT AVG(CASE WHEN first_date IS NOT NULL THEN first_date - second_date 
ELSE NULL END) 
   FROM example_dataset;`
   
   The query will timeout after 31 seconds with the Nereids error.
   
   ### Anything Else?
   
   _No response_
   
   ### 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]

Reply via email to