linrrzqqq opened a new pull request, #63605:
URL: https://github.com/apache/doris/pull/63605

   Problem Summary:
   
   Fix `VAR_SAMP`, `VARIANCE_SAMP`, and `STDDEV_SAMP` to return `NULL` when the 
number of valid input values is less than or equal to 1.
   
   Sample variance/stddev are undefined for `n <= 1`, so returning `0.0` is 
misleading. `VAR_POP` / `STDDEV_POP` keep the existing behavior and still 
return `0.0` for a single valid value.
   
   before:
   ```sql
   CREATE TABLE t (id INT, v DOUBLE) DUPLICATE KEY(id) DISTRIBUTED BY HASH(id) 
BUCKETS 1 PROPERTIES('replication_num'='1');
   INSERT INTO t VALUES (1, 5.0);  -- 单行
   
   SELECT VAR_SAMP(v), STDDEV_SAMP(v) FROM t;
   +-------------+----------------+
   | VAR_SAMP(v) | STDDEV_SAMP(v) |
   +-------------+----------------+
   |           0 |              0 |
   +-------------+----------------+
   ```
   
   now:
   ```sql
   SELECT VAR_SAMP(v), STDDEV_SAMP(v) FROM t;
   +-------------+----------------+
   | VAR_SAMP(v) | STDDEV_SAMP(v) |
   +-------------+----------------+
   |        NULL |           NULL |
   +-------------+----------------+
   ```
   
   


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