JoverZhang commented on code in PR #55940:
URL: https://github.com/apache/doris/pull/55940#discussion_r2343926374


##########
regression-test/data/query_p0/aggregate/support_type/regr_intercept/regr_intercept.out:
##########
@@ -6,17 +6,17 @@
 -990000.0
 
 -- !regr_intercept_int --
-1000001.0
+-9.999E9

Review Comment:
   According to
   
   - https://docs.snowflake.com/en/sql-reference/functions/regr_intercept
   - https://docs.snowflake.com/en/sql-reference/functions/regr_slope
   
   ```sql
   REGR_INTERCEPT(y, x) = AVG(y) - REGR_SLOPE(y, x) * AVG(x)
   REGR_SLOPE(y, x) = COVAR_POP(x, y) / VAR_POP(x)
   ```
   
   ### Verification
   
   ```sql
   select regr_intercept(col_int, col_bigint) from d_table;
   ```
   
   PostgreSQL
   
   ```sql
   select avg(col_int) - regr_slope(col_int, col_bigint) * avg(col_bigint) from 
d_table;
   +---------------+
   | ?column?      |
   |---------------|
   | -9999000000.0 |
   +---------------+
   ```
   
   Clickhouse (stable covariance/variance)
   
   ```sql
   SELECT avg(col_int) - ((covarPopStable(col_bigint, col_int) / 
varPopStable(col_bigint)) * avg(col_bigint))
   FROM d_table
      ┌─minus(avg(co⋯l_bigint)))─┐
   1. │              -9999000000 │ -- -10.00 billion
      └──────────────────────────┘
   
   ```



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