You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
The behavior of the stddev and variance aggregation differs from Postgres for less than three values. DataFusion crashes in these cases, whereas Postgres computes a variance for an array with two values and returns NULL for an array of one value.
In DataFusion CLI:
❯ select stddev(sq.column1) from (values (1.0), (2.0), (3.0)) as sq;
+--------------------+
| STDDEV(sq.column1) |
+--------------------+
| 1 |
+--------------------+
❯ select stddev(sq.column1) from (values (1.0), (2.0)) as sq;
ArrowError(ExternalError(Internal("At least two values are needed to calculate variance")))
❯ select stddev(sq.column1) from (values (1.0)) as sq;
ArrowError(ExternalError(Internal("At least two values are needed to calculate variance")))
In Postgres
❯ select stddev(sq.column1) from (values (1.0), (2.0), (3.0)) as sq;
1
❯ select stddev(sq.column1) from (values (1.0), (2.0)) as sq;
0.7071067811865475244
❯ select stddev(sq.column1) from (values (1.0)) as sq;
NULL
I would like to suggest DataFusion match the behavior of Postgres. Otherwise every usage of the variance function risks raising an error (depending on the distribution of the groupby column).
Additional context
Variance was first added by @realno in #1525.
The text was updated successfully, but these errors were encountered:
We should definitely calculate something for the two-sample case -- erroring simply doesn't make sense in that case. The second example has various behaviors going around, see the discussion in Snowflake docs. I agree with your sentiment that we should align with Postgres.
Describe the bug
The behavior of the stddev and variance aggregation differs from Postgres for less than three values. DataFusion crashes in these cases, whereas Postgres computes a variance for an array with two values and returns
NULL
for an array of one value.In DataFusion CLI:
In Postgres
I would like to suggest DataFusion match the behavior of Postgres. Otherwise every usage of the variance function risks raising an error (depending on the distribution of the groupby column).
Additional context
Variance was first added by @realno in #1525.
The text was updated successfully, but these errors were encountered: