[
https://issues.apache.org/jira/browse/FLINK-38400?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18029144#comment-18029144
]
lincoln lee edited comment on FLINK-38400 at 10/11/25 10:09 AM:
----------------------------------------------------------------
fixed in release-2.1: 1c44b5a1a96d77f0f4e60f62518a1dc563ca8b79
release-1.20: aab24714ab68d48bc611d4525623688663c171e0
was (Author: lincoln.86xy):
fixed in release-2.1: 1c44b5a1a96d77f0f4e60f62518a1dc563ca8b79
> STDDEV/VAR function with FILTER condition may cause wrong result
> ----------------------------------------------------------------
>
> Key: FLINK-38400
> URL: https://issues.apache.org/jira/browse/FLINK-38400
> Project: Flink
> Issue Type: Bug
> Affects Versions: 1.20.2, 2.1.0
> Reporter: lincoln lee
> Assignee: lincoln lee
> Priority: Major
> Labels: pull-request-available
> Fix For: 2.2.0, 2.1.1, 1.20.4
>
>
> As reported in https://issues.apache.org/jira/browse/CALCITE-7192, the
> following query may produce wrong result:
> {code:java}
> SELECT STDDEV_POP(salary) FILTER (WHERE salary > 1000) FROM employees;
> {code}
> the decomposition for STDDEV_POP will be:
> {code:java}
> SQRT((SUM(x * x) - SUM(x) * SUM(x) / COUNT(x))/ COUNT(x))
> {code}
> for the above example, the `SUM(salary * salary)` lost the filter `salary >
> 1000`.
>
> *Impact*
> This affects all functions that use the `reduceStddev` method:
> *STDDEV_POP FILTER (WHERE condition)*
> *STDDEV_SAMP FILTER (WHERE condition)*
> *VAR_POP FILTER (WHERE condition)*
> *VAR_SAMP FILTER (WHERE condition)*
> Before we bump up to calcite 1.41.0, we should port the fix first.
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)