dbms: added tests [#METR-2944].

This commit is contained in:
Alexey Milovidov 2014-03-24 00:40:55 +04:00
parent fc45d3cc5b
commit dae349ba00
71 changed files with 190 additions and 1 deletions

View File

@ -5,7 +5,7 @@
# Результаты сравниваются с эталонами.
QUERIES_DIR="./queries"
CLIENT_PROGRAM="clickhouse-client"
CLIENT_PROGRAM="curl -sS http://localhost:8123/ --data-binary @-"
COLOR_RESET="\033[0m"
@ -50,6 +50,10 @@ do
ERRORS=$(($ERRORS + 1))
echo -e "$MSG_FAIL - having stderror:"
cat $error_file
elif grep -q "Exception" $result_file; then
ERRORS=$(($ERRORS + 1))
echo -e "$MSG_FAIL - having exception:"
cat $result_file
elif [ ! -e "$reference_file" ]; then
# надо сгенерировать эталонный результат
if [ "$1" == "--generate" ]; then

View File

@ -0,0 +1 @@
SELECT count() FROM remote('127.0.0.{1,2}', system, one) WHERE arrayExists((x) -> x = 1, [1, 2, 3])

View File

@ -0,0 +1 @@
SET GLOBAL extremes = 1

View File

@ -0,0 +1,18 @@
{
"meta":
[
{
"name": "'Hello, world'",
"type": "String"
}
],
"data":
[
],
"rows": 0,
"rows_before_limit_at_least": 10
}

View File

@ -0,0 +1,2 @@
SELECT 'Hello, world' FROM (SELECT number FROM system.numbers LIMIT 10) WHERE number < 0
FORMAT JSONCompact

View File

@ -0,0 +1 @@
SET GLOBAL extremes = 0

View File

@ -0,0 +1 @@
['Hello','Goodbye']

View File

@ -0,0 +1 @@
SELECT ['Hello', 'Goodbye']

View File

@ -0,0 +1,2 @@
Hello
Goodbye

View File

@ -0,0 +1 @@
SELECT arrayJoin(['Hello', 'Goodbye'])

View File

@ -0,0 +1,2 @@
Hello
Goodbye

View File

@ -0,0 +1 @@
SELECT x FROM (SELECT arrayJoin(['Hello', 'Goodbye']) AS x)

View File

@ -0,0 +1,6 @@
Hello
Hello
Hello
Goodbye
Goodbye
Goodbye

View File

@ -0,0 +1 @@
SELECT x FROM (SELECT arrayJoin(['Hello', 'Goodbye']) AS x, [1, 2, 3] AS arr) ARRAY JOIN arr

View File

@ -0,0 +1,6 @@
Hello 1
Hello 2
Hello 3
Goodbye 1
Goodbye 2
Goodbye 3

View File

@ -0,0 +1 @@
SELECT x, a FROM (SELECT arrayJoin(['Hello', 'Goodbye']) AS x, [1, 2, 3] AS arr) ARRAY JOIN arr AS a

View File

@ -0,0 +1,6 @@
Hello 1 [1,2,3]
Hello 2 [1,2,3]
Hello 3 [1,2,3]
Goodbye 1 [1,2,3]
Goodbye 2 [1,2,3]
Goodbye 3 [1,2,3]

View File

@ -0,0 +1 @@
SELECT x, a, arr FROM (SELECT arrayJoin(['Hello', 'Goodbye']) AS x, [1, 2, 3] AS arr) ARRAY JOIN arr AS a

View File

@ -0,0 +1 @@
DROP TABLE IF EXISTS arrays_test

View File

@ -0,0 +1 @@
CREATE TABLE arrays_test (s String, arr Array(UInt8)) ENGINE = Memory

View File

@ -0,0 +1 @@
INSERT INTO arrays_test VALUES ('Hello', [1,2]), ('World', [3,4,5]), ('Goodbye', [])

View File

@ -0,0 +1,3 @@
Hello [1,2]
World [3,4,5]
Goodbye []

View File

@ -0,0 +1 @@
SELECT * FROM arrays_test

View File

@ -0,0 +1,5 @@
Hello 1
Hello 2
World 3
World 4
World 5

View File

@ -0,0 +1 @@
SELECT s, arr FROM arrays_test ARRAY JOIN arr

View File

@ -0,0 +1,5 @@
Hello [1,2] 1
Hello [1,2] 2
World [3,4,5] 3
World [3,4,5] 4
World [3,4,5] 5

View File

@ -0,0 +1 @@
SELECT s, arr, a FROM arrays_test ARRAY JOIN arr AS a

View File

@ -0,0 +1,5 @@
Hello [1,2] 1 1
Hello [1,2] 2 2
World [3,4,5] 3 1
World [3,4,5] 4 2
World [3,4,5] 5 3

View File

@ -0,0 +1 @@
SELECT s, arr, a, num FROM arrays_test ARRAY JOIN arr AS a, arrayEnumerate(arr) AS num

View File

@ -0,0 +1,5 @@
Hello [1,2] 1 1 [1,2]
Hello [1,2] 2 2 [1,2]
World [3,4,5] 3 1 [1,2,3]
World [3,4,5] 4 2 [1,2,3]
World [3,4,5] 5 3 [1,2,3]

View File

@ -0,0 +1 @@
SELECT s, arr, a, num, arrayEnumerate(arr) FROM arrays_test ARRAY JOIN arr AS a, arrayEnumerate(arr) AS num

View File

@ -0,0 +1,5 @@
Hello [1,2] 1 2
Hello [1,2] 2 3
World [3,4,5] 3 4
World [3,4,5] 4 5
World [3,4,5] 5 6

View File

@ -0,0 +1 @@
SELECT s, arr, a, mapped FROM arrays_test ARRAY JOIN arr AS a, arrayMap(x -> x + 1, arr) AS mapped

View File

@ -0,0 +1,5 @@
Hello [1,2] 1 1 2
Hello [1,2] 2 2 3
World [3,4,5] 3 1 4
World [3,4,5] 4 2 5
World [3,4,5] 5 3 6

View File

@ -0,0 +1 @@
SELECT s, arr, a, num, mapped FROM arrays_test ARRAY JOIN arr AS a, arrayEnumerate(arr) AS num, arrayMap(x -> x + 1, arr) AS mapped

View File

@ -0,0 +1 @@
DROP TABLE IF EXISTS nested_test

View File

@ -0,0 +1 @@
CREATE TABLE nested_test (s String, nest Nested(x UInt8, y UInt32)) ENGINE = Memory

View File

@ -0,0 +1 @@
INSERT INTO nested_test VALUES ('Hello', [1,2], [10,20]), ('World', [3,4,5], [30,40,50]), ('Goodbye', [], [])

View File

@ -0,0 +1,3 @@
Hello [1,2] [10,20]
World [3,4,5] [30,40,50]
Goodbye [] []

View File

@ -0,0 +1 @@
SELECT * FROM nested_test

View File

@ -0,0 +1,5 @@
Hello 1 10
Hello 2 20
World 3 30
World 4 40
World 5 50

View File

@ -0,0 +1 @@
SELECT s, nest.x, nest.y FROM nested_test ARRAY JOIN nest

View File

@ -0,0 +1,5 @@
Hello 1 [10,20]
Hello 2 [10,20]
World 3 [30,40,50]
World 4 [30,40,50]
World 5 [30,40,50]

View File

@ -0,0 +1 @@
SELECT s, nest.x, nest.y FROM nested_test ARRAY JOIN nest.x

View File

@ -0,0 +1,5 @@
Hello 1 10
Hello 2 20
World 3 30
World 4 40
World 5 50

View File

@ -0,0 +1 @@
SELECT s, nest.x, nest.y FROM nested_test ARRAY JOIN nest.x, nest.y

View File

@ -0,0 +1,5 @@
Hello 1 10
Hello 2 20
World 3 30
World 4 40
World 5 50

View File

@ -0,0 +1 @@
SELECT s, n.x, n.y FROM nested_test ARRAY JOIN nest AS n

View File

@ -0,0 +1,5 @@
Hello 1 10 [1,2]
Hello 2 20 [1,2]
World 3 30 [3,4,5]
World 4 40 [3,4,5]
World 5 50 [3,4,5]

View File

@ -0,0 +1 @@
SELECT s, n.x, n.y, nest.x FROM nested_test ARRAY JOIN nest AS n

View File

@ -0,0 +1,5 @@
Hello 1 10 [1,2] [10,20]
Hello 2 20 [1,2] [10,20]
World 3 30 [3,4,5] [30,40,50]
World 4 40 [3,4,5] [30,40,50]
World 5 50 [3,4,5] [30,40,50]

View File

@ -0,0 +1 @@
SELECT s, n.x, n.y, nest.x, nest.y FROM nested_test ARRAY JOIN nest AS n

View File

@ -0,0 +1,5 @@
Hello 1 10 [1,2] [10,20] 1
Hello 2 20 [1,2] [10,20] 2
World 3 30 [3,4,5] [30,40,50] 1
World 4 40 [3,4,5] [30,40,50] 2
World 5 50 [3,4,5] [30,40,50] 3

View File

@ -0,0 +1 @@
SELECT s, n.x, n.y, nest.x, nest.y, num FROM nested_test ARRAY JOIN nest AS n, arrayEnumerate(nest.x) AS num

View File

@ -0,0 +1,12 @@
0 10
1 10
5 10
7 10
2 10
6 10
4 10
8 10
3 10
9 10
0 100

View File

@ -0,0 +1 @@
SELECT number, count() / 0.1 FROM (SELECT number FROM system.numbers LIMIT 10) GROUP BY number WITH TOTALS HAVING count() > 0.1

View File

@ -0,0 +1,3 @@
0 10
0 10

View File

@ -0,0 +1 @@
SELECT dummy, count() / 0.1 GROUP BY dummy WITH TOTALS HAVING count() > 0.1

View File

@ -0,0 +1,18 @@
{
"meta":
[
{
"name": "count()",
"type": "UInt64"
}
],
"data":
[
],
"rows": 0,
"rows_before_limit_at_least": 1000
}

View File

@ -0,0 +1,2 @@
SELECT count() FROM (SELECT * FROM system.numbers LIMIT 1000) WHERE 1 IN (SELECT 0 WHERE 0)
FORMAT JSON

View File

@ -0,0 +1,2 @@
1
1

View File

@ -0,0 +1 @@
SELECT x FROM (SELECT DISTINCT 1 AS x, arrayJoin([1, 2]) AS y)