ClickHouse/tests/queries/0_stateless/00431_if_nulls.sql

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

146 lines
8.5 KiB
MySQL
Raw Normal View History

2017-03-07 21:45:25 +00:00
/* Condition could be:
* - constant, true
* - constant, false
* - constant, NULL
* - non constant, non nullable_00431
* - non constant, nullable_00431
2017-03-07 21:45:25 +00:00
*
* Then and else could be:
* - constant, not NULL
* - constant, NULL
* - non constant, non nullable_00431
* - non constant, nullable_00431
2017-03-07 21:45:25 +00:00
*
* Thus we have 5 * 4 * 4 = 80 combinations.
*/
DROP TABLE IF EXISTS nullable_00431;
2017-03-07 21:45:25 +00:00
CREATE VIEW nullable_00431
2017-03-07 21:45:25 +00:00
AS SELECT
1 AS constant_true,
0 AS constant_false,
NULL AS constant_null,
number % 3 = 1 AS cond_non_constant,
number % 3 = 2 ? NULL : (number % 3 = 1) AS cond_non_constant_nullable,
'Hello' AS then_constant,
'World' AS else_constant,
toString(number) AS then_non_constant,
toString(-number) AS else_non_constant,
nullIf(toString(number), '5') AS then_non_constant_nullable,
nullIf(toString(-number), '-5') AS else_non_constant_nullable
FROM system.numbers LIMIT 10;
2019-05-10 10:42:00 +00:00
SELECT '---------- constant_true ----------';
2017-03-07 21:45:25 +00:00
SELECT constant_true ? then_constant : else_constant AS res FROM nullable_00431;
SELECT constant_true ? then_constant : constant_null AS res FROM nullable_00431;
SELECT constant_true ? then_constant : else_non_constant AS res FROM nullable_00431;
SELECT constant_true ? then_constant : else_non_constant_nullable AS res FROM nullable_00431;
2017-03-07 21:45:25 +00:00
SELECT constant_true ? constant_null : else_constant AS res FROM nullable_00431;
SELECT constant_true ? constant_null : constant_null AS res FROM nullable_00431;
SELECT constant_true ? constant_null : else_non_constant AS res FROM nullable_00431;
SELECT constant_true ? constant_null : else_non_constant_nullable AS res FROM nullable_00431;
2017-03-07 21:45:25 +00:00
SELECT constant_true ? then_non_constant : else_constant AS res FROM nullable_00431;
SELECT constant_true ? then_non_constant : constant_null AS res FROM nullable_00431;
SELECT constant_true ? then_non_constant : else_non_constant AS res FROM nullable_00431;
SELECT constant_true ? then_non_constant : else_non_constant_nullable AS res FROM nullable_00431;
2017-03-07 21:45:25 +00:00
SELECT constant_true ? then_non_constant_nullable : else_constant AS res FROM nullable_00431;
SELECT constant_true ? then_non_constant_nullable : constant_null AS res FROM nullable_00431;
SELECT constant_true ? then_non_constant_nullable : else_non_constant AS res FROM nullable_00431;
SELECT constant_true ? then_non_constant_nullable : else_non_constant_nullable AS res FROM nullable_00431;
2017-03-07 21:45:25 +00:00
2019-05-10 10:42:00 +00:00
SELECT '---------- constant_false ----------';
2017-03-07 21:45:25 +00:00
SELECT constant_false ? then_constant : else_constant AS res FROM nullable_00431;
SELECT constant_false ? then_constant : constant_null AS res FROM nullable_00431;
SELECT constant_false ? then_constant : else_non_constant AS res FROM nullable_00431;
SELECT constant_false ? then_constant : else_non_constant_nullable AS res FROM nullable_00431;
2017-03-07 21:45:25 +00:00
SELECT constant_false ? constant_null : else_constant AS res FROM nullable_00431;
SELECT constant_false ? constant_null : constant_null AS res FROM nullable_00431;
SELECT constant_false ? constant_null : else_non_constant AS res FROM nullable_00431;
SELECT constant_false ? constant_null : else_non_constant_nullable AS res FROM nullable_00431;
2017-03-07 21:45:25 +00:00
SELECT constant_false ? then_non_constant : else_constant AS res FROM nullable_00431;
SELECT constant_false ? then_non_constant : constant_null AS res FROM nullable_00431;
SELECT constant_false ? then_non_constant : else_non_constant AS res FROM nullable_00431;
SELECT constant_false ? then_non_constant : else_non_constant_nullable AS res FROM nullable_00431;
2017-03-07 21:45:25 +00:00
SELECT constant_false ? then_non_constant_nullable : else_constant AS res FROM nullable_00431;
SELECT constant_false ? then_non_constant_nullable : constant_null AS res FROM nullable_00431;
SELECT constant_false ? then_non_constant_nullable : else_non_constant AS res FROM nullable_00431;
SELECT constant_false ? then_non_constant_nullable : else_non_constant_nullable AS res FROM nullable_00431;
2017-03-07 21:45:25 +00:00
2019-05-10 10:42:00 +00:00
SELECT '---------- constant_null ----------';
2017-03-07 21:45:25 +00:00
SELECT constant_null ? then_constant : else_constant AS res FROM nullable_00431;
SELECT constant_null ? then_constant : constant_null AS res FROM nullable_00431;
SELECT constant_null ? then_constant : else_non_constant AS res FROM nullable_00431;
SELECT constant_null ? then_constant : else_non_constant_nullable AS res FROM nullable_00431;
2017-03-07 21:45:25 +00:00
SELECT constant_null ? constant_null : else_constant AS res FROM nullable_00431;
SELECT constant_null ? constant_null : constant_null AS res FROM nullable_00431;
SELECT constant_null ? constant_null : else_non_constant AS res FROM nullable_00431;
SELECT constant_null ? constant_null : else_non_constant_nullable AS res FROM nullable_00431;
2017-03-07 21:45:25 +00:00
SELECT constant_null ? then_non_constant : else_constant AS res FROM nullable_00431;
SELECT constant_null ? then_non_constant : constant_null AS res FROM nullable_00431;
SELECT constant_null ? then_non_constant : else_non_constant AS res FROM nullable_00431;
SELECT constant_null ? then_non_constant : else_non_constant_nullable AS res FROM nullable_00431;
2017-03-07 21:45:25 +00:00
SELECT constant_null ? then_non_constant_nullable : else_constant AS res FROM nullable_00431;
SELECT constant_null ? then_non_constant_nullable : constant_null AS res FROM nullable_00431;
SELECT constant_null ? then_non_constant_nullable : else_non_constant AS res FROM nullable_00431;
SELECT constant_null ? then_non_constant_nullable : else_non_constant_nullable AS res FROM nullable_00431;
2017-03-07 21:45:25 +00:00
2019-05-10 10:42:00 +00:00
SELECT '---------- cond_non_constant ----------';
2017-03-07 21:45:25 +00:00
SELECT cond_non_constant ? then_constant : else_constant AS res FROM nullable_00431;
SELECT cond_non_constant ? then_constant : constant_null AS res FROM nullable_00431;
SELECT cond_non_constant ? then_constant : else_non_constant AS res FROM nullable_00431;
SELECT cond_non_constant ? then_constant : else_non_constant_nullable AS res FROM nullable_00431;
2017-03-07 21:45:25 +00:00
SELECT cond_non_constant ? constant_null : else_constant AS res FROM nullable_00431;
SELECT cond_non_constant ? constant_null : constant_null AS res FROM nullable_00431;
SELECT cond_non_constant ? constant_null : else_non_constant AS res FROM nullable_00431;
SELECT cond_non_constant ? constant_null : else_non_constant_nullable AS res FROM nullable_00431;
2017-03-07 21:45:25 +00:00
SELECT cond_non_constant ? then_non_constant : else_constant AS res FROM nullable_00431;
SELECT cond_non_constant ? then_non_constant : constant_null AS res FROM nullable_00431;
SELECT cond_non_constant ? then_non_constant : else_non_constant AS res FROM nullable_00431;
SELECT cond_non_constant ? then_non_constant : else_non_constant_nullable AS res FROM nullable_00431;
2017-03-07 21:45:25 +00:00
SELECT cond_non_constant ? then_non_constant_nullable : else_constant AS res FROM nullable_00431;
SELECT cond_non_constant ? then_non_constant_nullable : constant_null AS res FROM nullable_00431;
SELECT cond_non_constant ? then_non_constant_nullable : else_non_constant AS res FROM nullable_00431;
SELECT cond_non_constant ? then_non_constant_nullable : else_non_constant_nullable AS res FROM nullable_00431;
2017-03-07 21:45:25 +00:00
2019-05-10 10:42:00 +00:00
SELECT '---------- cond_non_constant_nullable ----------';
2017-03-07 21:45:25 +00:00
SELECT cond_non_constant_nullable ? then_constant : else_constant AS res FROM nullable_00431;
SELECT cond_non_constant_nullable ? then_constant : constant_null AS res FROM nullable_00431;
SELECT cond_non_constant_nullable ? then_constant : else_non_constant AS res FROM nullable_00431;
SELECT cond_non_constant_nullable ? then_constant : else_non_constant_nullable AS res FROM nullable_00431;
2017-03-07 21:45:25 +00:00
SELECT cond_non_constant_nullable ? constant_null : else_constant AS res FROM nullable_00431;
SELECT cond_non_constant_nullable ? constant_null : constant_null AS res FROM nullable_00431;
SELECT cond_non_constant_nullable ? constant_null : else_non_constant AS res FROM nullable_00431;
SELECT cond_non_constant_nullable ? constant_null : else_non_constant_nullable AS res FROM nullable_00431;
2017-03-07 21:45:25 +00:00
SELECT cond_non_constant_nullable ? then_non_constant : else_constant AS res FROM nullable_00431;
SELECT cond_non_constant_nullable ? then_non_constant : constant_null AS res FROM nullable_00431;
SELECT cond_non_constant_nullable ? then_non_constant : else_non_constant AS res FROM nullable_00431;
SELECT cond_non_constant_nullable ? then_non_constant : else_non_constant_nullable AS res FROM nullable_00431;
2017-03-07 21:45:25 +00:00
SELECT cond_non_constant_nullable ? then_non_constant_nullable : else_constant AS res FROM nullable_00431;
SELECT cond_non_constant_nullable ? then_non_constant_nullable : constant_null AS res FROM nullable_00431;
SELECT cond_non_constant_nullable ? then_non_constant_nullable : else_non_constant AS res FROM nullable_00431;
SELECT cond_non_constant_nullable ? then_non_constant_nullable : else_non_constant_nullable AS res FROM nullable_00431;
2017-03-07 21:45:25 +00:00
DROP TABLE nullable_00431;