-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
sqlite random/expr/slt_good_10.slt:
SELECT ALL + + MIN ( - CAST ( + 6 AS INTEGER ) ) * CASE WHEN NULL BETWEEN - 88 AND ( - - 91 ) * - AVG ( 95 ) THEN COUNT ( - 34 ) END
Both PG and sqlite have a result of 'null'. DF result is '-6'
The difference looks to be the handling of a case clause that doesn't match and doesn't have an else block. Most db's including PG have the result of a case block with no matches and no else to be 'null'. It seems DF is '1'
> select CASE WHEN NULL BETWEEN - 88 AND ( - - 91 ) * - AVG ( 95 ) THEN COUNT ( - 34 ) END;
+------------------------------------------------------------------------------------------------------+
| CASE WHEN NULL BETWEEN Int64(-88) AND (- Int64(-91)) * (- avg(Int64(95))) THEN count(Int64(-34)) END |
+------------------------------------------------------------------------------------------------------+
| 1 |
+------------------------------------------------------------------------------------------------------+
The following is duckdb's behavior with the same sql:
D select CASE WHEN NULL BETWEEN - 88 AND ( - - 91 ) * - AVG ( 95 ) THEN COUNT ( - 34 ) END;
┌───────────────────────────────────────────────────────────────────────────────────────┐
│ CASE WHEN ((NULL BETWEEN -88 AND (91 * -(avg(95))))) THEN (count(-34)) ELSE NULL END │
│ int64 │
├───────────────────────────────────────────────────────────────────────────────────────┤
│ │
└───────────────────────────────────────────────────────────────────────────────────────┘
D select typeof(CASE WHEN NULL BETWEEN - 88 AND ( - - 91 ) * - AVG ( 95 ) THEN COUNT ( - 34 ) END);
┌───────────────────────────────────────────────────────────────────────────────────────────────┐
│ typeof(CASE WHEN ((NULL BETWEEN -88 AND (91 * -(avg(95))))) THEN (count(-34)) ELSE NULL END) │
│ varchar │
├───────────────────────────────────────────────────────────────────────────────────────────────┤
│ BIGINT │
└───────────────────────────────────────────────────────────────────────────────────────────────┘
To Reproduce
sql above.
Expected behavior
I would expect the same result as PG and other db's.
Additional context
No response
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working