This is an automated email from the ASF dual-hosted git repository.

morningman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris-website.git


The following commit(s) were added to refs/heads/master by this push:
     new 54389b5dc0d [fix](doc) corr-welford.md: add ORDER BY for deterministic 
rows; mirror en/zh examples (#3794)
54389b5dc0d is described below

commit 54389b5dc0db4c0ce19ef6735d24eb56d63bede9
Author: boluor <[email protected]>
AuthorDate: Wed May 27 19:17:07 2026 -0700

    [fix](doc) corr-welford.md: add ORDER BY for deterministic rows; mirror 
en/zh examples (#3794)
    
    ## Summary
    
    Doc page (4.x): \`aggregate-functions/corr-welford.md\` (EN + ZH).
    
    Two problems on this page; this PR fixes both for both sides.
    
    **1. Non-deterministic result tables.** The shared examples on both
    sides used hash-partitioned tables without ORDER BY:
    
    \`\`\`sql
    select * from test_corr;
    select id, corr_welford(k1,k2) from test_corr group by id;
    \`\`\`
    
    The documented row orders did not match what the cluster actually
    produces on a single-node Apache Doris 4.1.1 cluster (EN's documented
    \`select *\` order was \`(1,20,22),(1,10,20)\` but the cluster returns
    \`(1,10,20),(1,20,22)\`; the \`group by\` was even more divergent — EN
    had \`2,4,3,1\`, ZH had \`1,2,3,4\`, cluster gave \`3,1,2,4\`). Added
    \`ORDER BY\` to both queries so users running the snippet see the same
    rows as the doc.
    
    **2. Each side was missing one example the other already had.**
    - EN gained ZH's \"no valid data → NULL\" example (\`where id = 999\`)
    and the matching \"If the group has no valid data, returns NULL\"
    return-value bullet.
    - ZH gained EN's \`select * from test_corr\` data-sample step.
    
    After this change both pages have the same 4-example structure: setup →
    show data → group-by → no-data.
    
    ## Verification
    
    Every SQL example was run against a single-node Apache Doris 4.1.1
    cluster — the result blocks in this PR are the verbatim mysql client
    output.
    
    ## Test plan
    
    - [x] Run the full setup + 4 examples on the cluster — all match.
    - [x] Compare EN and ZH structurally — same 4 examples in the same
    order.
    - [x] No prose changes beyond the one-line intro added to the no-data
    example.
    
    🤖 Generated with [Claude Code](https://claude.com/claude-code)
    
    Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
---
 .../aggregate-functions/corr-welford.md            | 52 +++++++++++++++-------
 .../aggregate-functions/corr-welford.md            | 43 ++++++++++++------
 2 files changed, 65 insertions(+), 30 deletions(-)

diff --git 
a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/aggregate-functions/corr-welford.md
 
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/aggregate-functions/corr-welford.md
index 1cad2eb765a..bb394239aae 100644
--- 
a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/aggregate-functions/corr-welford.md
+++ 
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/aggregate-functions/corr-welford.md
@@ -55,30 +55,50 @@ insert into test_corr values
 ```
 
 ```sql
-select id,corr_welford(k1,k2) from test_corr group by id;
+select * from test_corr order by id, k1, k2;
 ```
 
 ```text
-+------+---------------------+
-| id   | corr_welford(k1,k2) |
-+------+---------------------+
-|    1 |                   1 |
-|    2 |  0.4539206495016017 |
-|    3 |                NULL |
-|    4 |                   0 |
-+------+---------------------+
++------+------+------+
+| id   | k1   | k2   |
++------+------+------+
+|    1 |   10 |   20 |
+|    1 |   20 |   22 |
+|    2 |   25 |   20 |
+|    2 |   30 |   22 |
+|    2 |   36 |   21 |
+|    3 |   25 | NULL |
+|    4 |   25 |   20 |
+|    4 |   25 |   21 |
+|    4 |   25 |   22 |
++------+------+------+
 ```
 
 ```sql
-select corr_welford(k1,k2) from test_corr where id=999;
+select id, corr_welford(k1, k2) from test_corr group by id order by id;
 ```
 
-组内没有有效数据。
+```text
++------+----------------------+
+| id   | corr_welford(k1, k2) |
++------+----------------------+
+|    1 |                    1 |
+|    2 |   0.4539206495016017 |
+|    3 |                 NULL |
+|    4 |                    0 |
++------+----------------------+
+```
+
+当分组内没有有效的 `(k1, k2)` 数据对时(此处 `id = 999` 没有匹配行),聚合返回 NULL。
+
+```sql
+select corr_welford(k1, k2) from test_corr where id = 999;
+```
 
 ```text
-+---------------------+
-| corr_welford(k1,k2) |
-+---------------------+
-|                NULL |
-+---------------------+
++----------------------+
+| corr_welford(k1, k2) |
++----------------------+
+|                 NULL |
++----------------------+
 ```
\ No newline at end of file
diff --git 
a/versioned_docs/version-4.x/sql-manual/sql-functions/aggregate-functions/corr-welford.md
 
b/versioned_docs/version-4.x/sql-manual/sql-functions/aggregate-functions/corr-welford.md
index 98055a6a635..ee9f5c588d2 100755
--- 
a/versioned_docs/version-4.x/sql-manual/sql-functions/aggregate-functions/corr-welford.md
+++ 
b/versioned_docs/version-4.x/sql-manual/sql-functions/aggregate-functions/corr-welford.md
@@ -29,6 +29,7 @@ Returns a DOUBLE type value, which is the covariance of expr1 
and expr2 divided
 
 - If the standard deviation of expr1 or expr2 is 0, returns 0.
 - If expr1 or expr2 contains NULL values, those rows are excluded from the 
final result.
+- If the group has no valid data, returns NULL.
 
 ## Example
 
@@ -54,36 +55,50 @@ insert into test_corr values
 ```
 
 ```sql
-select * from test_corr;
+select * from test_corr order by id, k1, k2;
 ```
 
 ```text
 +------+------+------+
 | id   | k1   | k2   |
 +------+------+------+
-|    1 |   20 |   22 |
 |    1 |   10 |   20 |
-|    2 |   36 |   21 |
-|    2 |   30 |   22 |
+|    1 |   20 |   22 |
 |    2 |   25 |   20 |
+|    2 |   30 |   22 |
+|    2 |   36 |   21 |
 |    3 |   25 | NULL |
+|    4 |   25 |   20 |
 |    4 |   25 |   21 |
 |    4 |   25 |   22 |
-|    4 |   25 |   20 |
 +------+------+------+
 ```
 
 ```sql
-select id,corr_welford(k1,k2) from test_corr group by id;
+select id, corr_welford(k1, k2) from test_corr group by id order by id;
+```
+
+```text
++------+----------------------+
+| id   | corr_welford(k1, k2) |
++------+----------------------+
+|    1 |                    1 |
+|    2 |   0.4539206495016017 |
+|    3 |                 NULL |
+|    4 |                    0 |
++------+----------------------+
+```
+
+When the group contains no valid `(k1, k2)` pairs (here, no rows match `id = 
999`), the aggregate returns NULL.
+
+```sql
+select corr_welford(k1, k2) from test_corr where id = 999;
 ```
 
 ```text
-+------+---------------------+
-| id   | corr_welford(k1,k2) |
-+------+---------------------+
-|    2 |  0.4539206495016017 |
-|    4 |                   0 |
-|    3 |                NULL |
-|    1 |                   1 |
-+------+---------------------+
++----------------------+
+| corr_welford(k1, k2) |
++----------------------+
+|                 NULL |
++----------------------+
 ```


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to