Added test [#CLICKHOUSE-2873].

This commit is contained in:
Alexey Milovidov 2017-03-08 00:45:25 +03:00
parent f88b46c259
commit 520e891190
2 changed files with 940 additions and 0 deletions

View File

@ -0,0 +1,800 @@
Hello
Hello
Hello
Hello
Hello
Hello
Hello
Hello
Hello
Hello
Hello
Hello
Hello
Hello
Hello
Hello
Hello
Hello
Hello
Hello
Hello
Hello
Hello
Hello
Hello
Hello
Hello
Hello
Hello
Hello
Hello
Hello
Hello
Hello
Hello
Hello
Hello
Hello
Hello
Hello
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
\N
6
7
8
9
0
1
2
3
4
\N
6
7
8
9
0
1
2
3
4
\N
6
7
8
9
0
1
2
3
4
\N
6
7
8
9
World
World
World
World
World
World
World
World
World
World
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
0
-1
-2
-3
-4
-5
-6
-7
-8
-9
0
-1
-2
-3
-4
\N
-6
-7
-8
-9
World
World
World
World
World
World
World
World
World
World
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
0
-1
-2
-3
-4
-5
-6
-7
-8
-9
0
-1
-2
-3
-4
\N
-6
-7
-8
-9
World
World
World
World
World
World
World
World
World
World
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
0
-1
-2
-3
-4
-5
-6
-7
-8
-9
0
-1
-2
-3
-4
\N
-6
-7
-8
-9
World
World
World
World
World
World
World
World
World
World
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
0
-1
-2
-3
-4
-5
-6
-7
-8
-9
0
-1
-2
-3
-4
\N
-6
-7
-8
-9
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
World
Hello
World
World
Hello
World
World
Hello
World
World
\N
Hello
\N
\N
Hello
\N
\N
Hello
\N
\N
0
Hello
-2
-3
Hello
-5
-6
Hello
-8
-9
0
Hello
-2
-3
Hello
\N
-6
Hello
-8
-9
World
\N
World
World
\N
World
World
\N
World
World
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
0
\N
-2
-3
\N
-5
-6
\N
-8
-9
0
\N
-2
-3
\N
\N
-6
\N
-8
-9
World
1
World
World
4
World
World
7
World
World
\N
1
\N
\N
4
\N
\N
7
\N
\N
0
1
-2
-3
4
-5
-6
7
-8
-9
0
1
-2
-3
4
\N
-6
7
-8
-9
World
1
World
World
4
World
World
7
World
World
\N
1
\N
\N
4
\N
\N
7
\N
\N
0
1
-2
-3
4
-5
-6
7
-8
-9
0
1
-2
-3
4
\N
-6
7
-8
-9
World
Hello
\N
World
Hello
\N
World
Hello
\N
World
\N
Hello
\N
\N
Hello
\N
\N
Hello
\N
\N
0
Hello
\N
-3
Hello
\N
-6
Hello
\N
-9
0
Hello
\N
-3
Hello
\N
-6
Hello
\N
-9
World
\N
\N
World
\N
\N
World
\N
\N
World
\N
\N
\N
\N
\N
\N
\N
\N
\N
\N
0
\N
\N
-3
\N
\N
-6
\N
\N
-9
0
\N
\N
-3
\N
\N
-6
\N
\N
-9
World
1
\N
World
4
\N
World
7
\N
World
\N
1
\N
\N
4
\N
\N
7
\N
\N
0
1
\N
-3
4
\N
-6
7
\N
-9
0
1
\N
-3
4
\N
-6
7
\N
-9
World
1
\N
World
4
\N
World
7
\N
World
\N
1
\N
\N
4
\N
\N
7
\N
\N
0
1
\N
-3
4
\N
-6
7
\N
-9
0
1
\N
-3
4
\N
-6
7
\N
-9

View File

@ -0,0 +1,140 @@
/* Condition could be:
* - constant, true
* - constant, false
* - constant, NULL
* - non constant, non nullable
* - non constant, nullable
*
* Then and else could be:
* - constant, not NULL
* - constant, NULL
* - non constant, non nullable
* - non constant, nullable
*
* Thus we have 5 * 4 * 4 = 80 combinations.
*/
DROP TABLE IF EXISTS test.nullable;
CREATE VIEW test.nullable
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;
SELECT constant_true ? then_constant : else_constant AS res FROM test.nullable;
SELECT constant_true ? then_constant : constant_null AS res FROM test.nullable;
SELECT constant_true ? then_constant : else_non_constant AS res FROM test.nullable;
SELECT constant_true ? then_constant : else_non_constant_nullable AS res FROM test.nullable;
SELECT constant_true ? constant_null : else_constant AS res FROM test.nullable;
SELECT constant_true ? constant_null : constant_null AS res FROM test.nullable;
SELECT constant_true ? constant_null : else_non_constant AS res FROM test.nullable;
SELECT constant_true ? constant_null : else_non_constant_nullable AS res FROM test.nullable;
SELECT constant_true ? then_non_constant : else_constant AS res FROM test.nullable;
SELECT constant_true ? then_non_constant : constant_null AS res FROM test.nullable;
SELECT constant_true ? then_non_constant : else_non_constant AS res FROM test.nullable;
SELECT constant_true ? then_non_constant : else_non_constant_nullable AS res FROM test.nullable;
SELECT constant_true ? then_non_constant_nullable : else_constant AS res FROM test.nullable;
SELECT constant_true ? then_non_constant_nullable : constant_null AS res FROM test.nullable;
SELECT constant_true ? then_non_constant_nullable : else_non_constant AS res FROM test.nullable;
SELECT constant_true ? then_non_constant_nullable : else_non_constant_nullable AS res FROM test.nullable;
SELECT constant_false ? then_constant : else_constant AS res FROM test.nullable;
SELECT constant_false ? then_constant : constant_null AS res FROM test.nullable;
SELECT constant_false ? then_constant : else_non_constant AS res FROM test.nullable;
SELECT constant_false ? then_constant : else_non_constant_nullable AS res FROM test.nullable;
SELECT constant_false ? constant_null : else_constant AS res FROM test.nullable;
SELECT constant_false ? constant_null : constant_null AS res FROM test.nullable;
SELECT constant_false ? constant_null : else_non_constant AS res FROM test.nullable;
SELECT constant_false ? constant_null : else_non_constant_nullable AS res FROM test.nullable;
SELECT constant_false ? then_non_constant : else_constant AS res FROM test.nullable;
SELECT constant_false ? then_non_constant : constant_null AS res FROM test.nullable;
SELECT constant_false ? then_non_constant : else_non_constant AS res FROM test.nullable;
SELECT constant_false ? then_non_constant : else_non_constant_nullable AS res FROM test.nullable;
SELECT constant_false ? then_non_constant_nullable : else_constant AS res FROM test.nullable;
SELECT constant_false ? then_non_constant_nullable : constant_null AS res FROM test.nullable;
SELECT constant_false ? then_non_constant_nullable : else_non_constant AS res FROM test.nullable;
SELECT constant_false ? then_non_constant_nullable : else_non_constant_nullable AS res FROM test.nullable;
SELECT constant_null ? then_constant : else_constant AS res FROM test.nullable;
SELECT constant_null ? then_constant : constant_null AS res FROM test.nullable;
SELECT constant_null ? then_constant : else_non_constant AS res FROM test.nullable;
SELECT constant_null ? then_constant : else_non_constant_nullable AS res FROM test.nullable;
SELECT constant_null ? constant_null : else_constant AS res FROM test.nullable;
SELECT constant_null ? constant_null : constant_null AS res FROM test.nullable;
SELECT constant_null ? constant_null : else_non_constant AS res FROM test.nullable;
SELECT constant_null ? constant_null : else_non_constant_nullable AS res FROM test.nullable;
SELECT constant_null ? then_non_constant : else_constant AS res FROM test.nullable;
SELECT constant_null ? then_non_constant : constant_null AS res FROM test.nullable;
SELECT constant_null ? then_non_constant : else_non_constant AS res FROM test.nullable;
SELECT constant_null ? then_non_constant : else_non_constant_nullable AS res FROM test.nullable;
SELECT constant_null ? then_non_constant_nullable : else_constant AS res FROM test.nullable;
SELECT constant_null ? then_non_constant_nullable : constant_null AS res FROM test.nullable;
SELECT constant_null ? then_non_constant_nullable : else_non_constant AS res FROM test.nullable;
SELECT constant_null ? then_non_constant_nullable : else_non_constant_nullable AS res FROM test.nullable;
SELECT cond_non_constant ? then_constant : else_constant AS res FROM test.nullable;
SELECT cond_non_constant ? then_constant : constant_null AS res FROM test.nullable;
SELECT cond_non_constant ? then_constant : else_non_constant AS res FROM test.nullable;
SELECT cond_non_constant ? then_constant : else_non_constant_nullable AS res FROM test.nullable;
SELECT cond_non_constant ? constant_null : else_constant AS res FROM test.nullable;
SELECT cond_non_constant ? constant_null : constant_null AS res FROM test.nullable;
SELECT cond_non_constant ? constant_null : else_non_constant AS res FROM test.nullable;
SELECT cond_non_constant ? constant_null : else_non_constant_nullable AS res FROM test.nullable;
SELECT cond_non_constant ? then_non_constant : else_constant AS res FROM test.nullable;
SELECT cond_non_constant ? then_non_constant : constant_null AS res FROM test.nullable;
SELECT cond_non_constant ? then_non_constant : else_non_constant AS res FROM test.nullable;
SELECT cond_non_constant ? then_non_constant : else_non_constant_nullable AS res FROM test.nullable;
SELECT cond_non_constant ? then_non_constant_nullable : else_constant AS res FROM test.nullable;
SELECT cond_non_constant ? then_non_constant_nullable : constant_null AS res FROM test.nullable;
SELECT cond_non_constant ? then_non_constant_nullable : else_non_constant AS res FROM test.nullable;
SELECT cond_non_constant ? then_non_constant_nullable : else_non_constant_nullable AS res FROM test.nullable;
SELECT cond_non_constant_nullable ? then_constant : else_constant AS res FROM test.nullable;
SELECT cond_non_constant_nullable ? then_constant : constant_null AS res FROM test.nullable;
SELECT cond_non_constant_nullable ? then_constant : else_non_constant AS res FROM test.nullable;
SELECT cond_non_constant_nullable ? then_constant : else_non_constant_nullable AS res FROM test.nullable;
SELECT cond_non_constant_nullable ? constant_null : else_constant AS res FROM test.nullable;
SELECT cond_non_constant_nullable ? constant_null : constant_null AS res FROM test.nullable;
SELECT cond_non_constant_nullable ? constant_null : else_non_constant AS res FROM test.nullable;
SELECT cond_non_constant_nullable ? constant_null : else_non_constant_nullable AS res FROM test.nullable;
SELECT cond_non_constant_nullable ? then_non_constant : else_constant AS res FROM test.nullable;
SELECT cond_non_constant_nullable ? then_non_constant : constant_null AS res FROM test.nullable;
SELECT cond_non_constant_nullable ? then_non_constant : else_non_constant AS res FROM test.nullable;
SELECT cond_non_constant_nullable ? then_non_constant : else_non_constant_nullable AS res FROM test.nullable;
SELECT cond_non_constant_nullable ? then_non_constant_nullable : else_constant AS res FROM test.nullable;
SELECT cond_non_constant_nullable ? then_non_constant_nullable : constant_null AS res FROM test.nullable;
SELECT cond_non_constant_nullable ? then_non_constant_nullable : else_non_constant AS res FROM test.nullable;
SELECT cond_non_constant_nullable ? then_non_constant_nullable : else_non_constant_nullable AS res FROM test.nullable;
DROP TABLE test.nullable;