alamb commented on code in PR #16927: URL: https://github.com/apache/datafusion/pull/16927#discussion_r2237554782
########## docs/source/user-guide/sql/aggregate_functions.md: ########## @@ -644,6 +688,30 @@ regr_count(expression_y, expression_x) - **expression_y**: Dependent variable expression to operate on. Can be a constant, column, or function, and any combination of operators. - **expression_x**: Independent variable expression to operate on. Can be a constant, column, or function, and any combination of operators. +### Example + +consider the following table: + +```sql +> create table daily_metrics(int day, int user_signups) as values (1,100), (2,120), (3, NULL), (4,110), (5,NULL); +> select * from daily_metrics; ++-----+---------------+ +| day | user_signups | +| --- | ------------- | +| 1 | 100 | +| 2 | 120 | +| 3 | NULL | +| 4 | 110 | +| 5 | NULL | ++-----+---------------+ +``` + +```sql +SELECT regr_count(user_signups, day) AS valid_pairs +FROM daily_metrics; -- output = 3 pairs i.e (1,100),(2,120),(4,110) + Review Comment: ```suggestion SELECT regr_count(user_signups, day) AS valid_pairs FROM daily_metrics; +-------------+ | valid_pairs | +-------------+ | 3 | +-------------+ 1 row(s) fetched. Elapsed 0.001 seconds. ``` ########## docs/source/user-guide/sql/aggregate_functions.md: ########## @@ -644,6 +688,30 @@ regr_count(expression_y, expression_x) - **expression_y**: Dependent variable expression to operate on. Can be a constant, column, or function, and any combination of operators. - **expression_x**: Independent variable expression to operate on. Can be a constant, column, or function, and any combination of operators. +### Example + +consider the following table: + +```sql +> create table daily_metrics(int day, int user_signups) as values (1,100), (2,120), (3, NULL), (4,110), (5,NULL); Review Comment: ```suggestion > create table daily_metrics(day int, user_signups int) as values (1,100), (2,120), (3, NULL), (4,110), (5,NULL); ``` ########## docs/source/user-guide/sql/aggregate_functions.md: ########## @@ -657,6 +725,30 @@ regr_intercept(expression_y, expression_x) - **expression_y**: Dependent variable expression to operate on. Can be a constant, column, or function, and any combination of operators. - **expression_x**: Independent variable expression to operate on. Can be a constant, column, or function, and any combination of operators. +### Example + +consider the following table: + +```sql +>create table weekly_performances(int day, int user_signups) as values (1,60), (2,65), (3, 70), (4,75), (5,80); +> select * from weekly_performances; ++------+---------------------+ +| week | productivity_score | Review Comment: this table doesn't have the same columns (it should have user_signups, right)? ########## docs/source/user-guide/sql/aggregate_functions.md: ########## @@ -631,6 +654,27 @@ regr_avgy(expression_y, expression_x) - **expression_y**: Dependent variable expression to operate on. Can be a constant, column, or function, and any combination of operators. - **expression_x**: Independent variable expression to operate on. Can be a constant, column, or function, and any combination of operators. +### Example + +```sql +> create table daily_temperature(day int, temperature int) as values (1,30), (2,32), (3, NULL), (4,35), (5,36); +> select * from daily_temperature; ++-----+-------------+ +| day | temperature | +| --- | ----------- | +| 1 | 30 | +| 2 | 32 | +| 3 | NULL | +| 4 | 35 | +| 5 | 36 | ++-----+-------------+ +``` + +```sql +SELECT regr_avgy(temperature, day) AS avg_temperature --temperature as Dependent Variable(Y) +FROM daily_temperature; --output = 33.25 Review Comment: ```suggestion SELECT regr_avgy(temperature, day) AS avg_temperature --temperature as Dependent Variable(Y) FROM daily_temperature; +-----------------+ | avg_temperature | +-----------------+ | 33.25 | +-----------------+ 1 row(s) fetched. Elapsed 0.000 seconds. ``` -- 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: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org