cockroachdb / cockroach

CockroachDB — the cloud native, distributed SQL database designed for high availability, effortless scale, and control over data placement.
https://www.cockroachlabs.com
Other
30.13k stars 3.81k forks source link

sql: FILTER applied after evaluating aggregate function expression #45845

Open andy-kimball opened 4 years ago

andy-kimball commented 4 years ago

Repro:

root@:26257/defaultdb> SELECT SUM(1/x) FILTER (WHERE x > 0) FROM (VALUES (0), (1)) t(x);
ERROR: division by zero

EXPECTED: No error, like PG:

template1=# SELECT SUM(1/x) FILTER (WHERE x > 0) FROM (VALUES (0), (1)) t(x);
 sum
-----
   1

Jira issue: CRDB-5125

andy-kimball commented 4 years ago

Seems hard for us to fix, given the way that we compile aggregate and FILTER expressions. But I filed it so that we're aware of this small behavior difference, and in case we come up with some reasonable way to match semantics.

github-actions[bot] commented 1 year ago

We have marked this issue as stale because it has been inactive for 18 months. If this issue is still relevant, removing the stale label or adding a comment will keep it active. Otherwise, we'll close it in 10 days to keep the issue queue tidy. Thank you for your contribution to CockroachDB!

andy-kimball commented 1 year ago

Still an issue.