WeisonWei opened a new issue, #52552:
URL: https://github.com/apache/doris/issues/52552

   ### Search before asking
   
   - [x] I had searched in the 
[issues](https://github.com/apache/doris/issues?q=is%3Aissue) and found no 
similar issues.
   
   
   ### Description
   
   Request to add `REGR_SLOPE` and other regression statistical functions to 
Apache Doris to support linear regression calculations in data analysis. 
Currently, Doris lacks these important statistical analysis functions.
   
   
   This query fails in Doris
   ``` sql
   SELECT REGR_SLOPE(y, x) AS slope
   FROM (
       SELECT 1 AS x, 2 AS y
       UNION ALL SELECT 2 AS x, 4 AS y
       UNION ALL SELECT 3 AS x, 6 AS y
       UNION ALL SELECT 4 AS x, 8 AS y
   ) t;
   ```
   
   Currently requires manual calculation, complex and error-prone
   ``` sql
   SELECT 
       (COUNT(*) * SUM(x * y) - SUM(x) * SUM(y)) / 
       (COUNT(*) * SUM(x * x) - SUM(x) * SUM(x)) AS slope
   FROM your_data;
   ```
   
   regr_slope in Trino/Presto : 
https://trino.io/docs/current/functions/aggregate.html#regr_slope 
   
   ### Use case
   
   ``` sql
    This query fails in Doris
   SELECT REGR_SLOPE(y, x) AS slope
   FROM (
       SELECT 1 AS x, 2 AS y
       UNION ALL SELECT 2 AS x, 4 AS y
       UNION ALL SELECT 3 AS x, 6 AS y
       UNION ALL SELECT 4 AS x, 8 AS y
   ) t;
   
   ```
   
   
   ### Related issues
   
   _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