Copilot commented on code in PR #3544: URL: https://github.com/apache/doris-website/pull/3544#discussion_r3072239110
########## docs/sql-manual/sql-functions/aggregate-functions/regr-slope.md: ########## @@ -29,54 +28,37 @@ REGR_SLOPE(<y>, <x>) Returns a Double value representing the slope of the linear regression line. If there are no rows in the group, or all rows contain NULLs for the expressions, the function returns `NULL`. -## Examples +## Example ```sql --- setup -CREATE TABLE test_regr_slope ( +CREATE TABLE test_regr ( `id` int, - `x` int, - `y` int + `x` double, + `y` double ) DUPLICATE KEY (`id`) DISTRIBUTED BY HASH(`id`) BUCKETS AUTO PROPERTIES ( "replication_allocation" = "tag.location.default: 1" ); --- Insert example data -INSERT INTO test_regr_slope VALUES -(1, 18, 13), -(2, 14, 27), -(3, 12, 2), -(4, 5, 6), -(5, 10, 20); -``` - -```sql -SELECT REGR_SLOPE(y, x) FROM test_regr_slope; -``` - -Calculate the linear regression slope of x and y. - - -```text -+--------------------+ -| REGR_SLOPE(y, x) | -+--------------------+ -| 0.6853448275862069 | -+--------------------+ +INSERT INTO test_regr VALUES +(1, 0, NULL), +(2, 1, 3), +(2, 2, 5), +(2, 3, 7), +(2, 4, 9), +(2, 5, NULL); ``` ```sql -SELECT REGR_SLOPE(y, x) FROM test_regr_slope where x>100; +SELECT id, REGR_SLOPE(y, x) FROM test_regr GROUP BY id ORDER BY id; ``` -When there are no rows in the group, the function returns `NULL`. - ```text -+------------------+ -| REGR_SLOPE(y, x) | -+------------------+ -| NULL | -+------------------+ ++------+--------------------+ +| id | REGR_SLOPE(y, x) | Review Comment: In the example output block, the ASCII table header line doesn’t match the separator width (extra/missing spaces before the trailing `|`). Please adjust spacing so the header/rows align with the `+------+...+` separators for readability. ```suggestion | id | REGR_SLOPE(y, x) | ``` ########## docs/sql-manual/sql-functions/aggregate-functions/regr-intercept.md: ########## @@ -29,52 +25,40 @@ REGR_INTERCEPT(<y>, <x>) ## Return Value -Returns a Double value representing the intercept of the univariate linear regression line for non-null pairs in a group. If there are no rows, or only rows that contain nulls, the function returns NULL. +Returns a Double value representing the intercept of the linear regression line. +If there are no rows in the group, or all rows contain NULLs for the expressions, the function returns `NULL`. -## Examples +## Example ```sql --- Create sample table -CREATE TABLE test_regr_intercept ( +CREATE TABLE test_regr ( `id` int, - `x` int, - `y` int + `x` double, + `y` double ) DUPLICATE KEY (`id`) DISTRIBUTED BY HASH(`id`) BUCKETS AUTO PROPERTIES ( "replication_allocation" = "tag.location.default: 1" ); --- Insert sample data -INSERT INTO test_regr_intercept VALUES -(1, 18, 13), -(2, 14, 27), -(3, 12, 2), -(4, 5, 6), -(5, 10, 20); - --- Calculate the linear regression intercept of x and y -SELECT REGR_INTERCEPT(y, x) FROM test_regr_intercept; -``` - -```text -+----------------------+ -| REGR_INTERCEPT(y, x) | -+----------------------+ -| 5.512931034482759 | -+----------------------+ +INSERT INTO test_regr VALUES +(1, 0, NULL), +(2, 1, 3), +(2, 2, 5), +(2, 3, 7), +(2, 4, 9), +(2, 5, NULL); ``` ```sql -SELECT REGR_INTERCEPT(y, x) FROM test_regr_intercept where x>100; +SELECT id, REGR_INTERCEPT(y, x) FROM test_regr GROUP BY id ORDER BY id; ``` -When there are no rows in the group, the function returns `NULL`. - ```text -+----------------------+ -| REGR_INTERCEPT(y, x) | -+----------------------+ -| NULL | -+----------------------+ ++------+------------------------+ +| id | REGR_INTERCEPT(y, x) | ++------+------------------------+ +| 1 | NULL | +| 2 | 1.0 | Review Comment: In the example output block, the ASCII table columns are misaligned (separator width vs header/data row spacing), which makes the snippet harder to read. Please normalize the spacing so the header and rows match the `+----+` separators (similar to the aligned output in the versioned 4.x doc). ```suggestion | 2 | 1.0 | ``` -- 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]
