Make less calls to clickhouse-client in tests

By @achulkov2
This commit is contained in:
Arthur Petukhovsky 2020-05-31 21:47:54 +03:00
parent e576919626
commit 54a746e24d
3 changed files with 83 additions and 104 deletions

View File

@ -9,21 +9,20 @@ declare -a SearchTypes=("POLYGON" "POLYGON_INDEX_EACH" "POLYGON_INDEX_CELL")
tar -xf ${CURDIR}/01037_test_data_search.tar.gz -C ${CURDIR}
$CLICKHOUSE_CLIENT --query="DROP DATABASE IF EXISTS test_01037;"
$CLICKHOUSE_CLIENT --query="CREATE DATABASE test_01037 Engine = Ordinary;"
$CLICKHOUSE_CLIENT --query="DROP TABLE IF EXISTS test_01037.points;"
$CLICKHOUSE_CLIENT --query="CREATE TABLE test_01037.points (x Float64, y Float64) ENGINE = Memory;"
$CLICKHOUSE_CLIENT -n --query="
DROP DATABASE IF EXISTS test_01037;
CREATE DATABASE test_01037 Engine = Ordinary;
DROP TABLE IF EXISTS test_01037.points;
CREATE TABLE test_01037.points (x Float64, y Float64) ENGINE = Memory;
"
$CLICKHOUSE_CLIENT --query="INSERT INTO test_01037.points FORMAT TSV" --max_insert_block_size=100000 < "${CURDIR}/01037_point_data"
rm ${CURDIR}/01037_point_data
$CLICKHOUSE_CLIENT --query="DROP TABLE IF EXISTS test_01037.polygons_array;"
$CLICKHOUSE_CLIENT -n --query="
DROP TABLE IF EXISTS test_01037.polygons_array;
$CLICKHOUSE_CLIENT --query="
CREATE TABLE test_01037.polygons_array
(
key Array(Array(Array(Array(Float64)))),
@ -37,11 +36,13 @@ $CLICKHOUSE_CLIENT --query="INSERT INTO test_01037.polygons_array FORMAT JSONEac
rm ${CURDIR}/01037_polygon_data
$CLICKHOUSE_CLIENT --query="DROP DICTIONARY IF EXISTS test_01037.dict_array;"
for type in ${SearchTypes[@]};
do
do
outputFile="${TMP_DIR}/results${type}.out"
$CLICKHOUSE_CLIENT -n --query="
DROP DICTIONARY IF EXISTS test_01037.dict_array;
CREATE DICTIONARY test_01037.dict_array
(
key Array(Array(Array(Array(Float64)))),
@ -51,19 +52,16 @@ do
PRIMARY KEY key
SOURCE(CLICKHOUSE(HOST 'localhost' PORT 9000 USER 'default' TABLE 'polygons_array' PASSWORD '' DB 'test_01037'))
LIFETIME(0)
LAYOUT($type());"
LAYOUT($type());
outputFile="${TMP_DIR}/results${type}.out"
$CLICKHOUSE_CLIENT -n --query="
select 'dictGet', 'test_01037.dict_array' as dict_name, tuple(x, y) as key,
dictGet(dict_name, 'value', key) from test_01037.points order by x, y;
" > $outputFile
diff -q "${CURDIR}/01037_polygon_dicts_correctness_all.ans" "$outputFile"
$CLICKHOUSE_CLIENT --query="DROP DICTIONARY test_01037.dict_array;"
done
$CLICKHOUSE_CLIENT --query="DROP TABLE test_01037.points;"
$CLICKHOUSE_CLIENT --query="DROP DATABASE test_01037;"
$CLICKHOUSE_CLIENT -n --query="
DROP TABLE test_01037.points;
DROP DATABASE test_01037;
"

View File

@ -9,21 +9,20 @@ declare -a SearchTypes=("POLYGON_INDEX_EACH" "POLYGON_INDEX_CELL")
tar -xf ${CURDIR}/01037_test_data_perf.tar.gz -C ${CURDIR}
$CLICKHOUSE_CLIENT --query="DROP DATABASE IF EXISTS test_01037;"
$CLICKHOUSE_CLIENT --query="CREATE DATABASE test_01037 Engine = Ordinary;"
$CLICKHOUSE_CLIENT --query="DROP TABLE IF EXISTS test_01037.points;"
$CLICKHOUSE_CLIENT --query="CREATE TABLE test_01037.points (x Float64, y Float64) ENGINE = Memory;"
$CLICKHOUSE_CLIENT -n --query="
DROP DATABASE IF EXISTS test_01037;
CREATE DATABASE test_01037 Engine = Ordinary;
DROP TABLE IF EXISTS test_01037.points;
CREATE TABLE test_01037.points (x Float64, y Float64) ENGINE = Memory;
"
$CLICKHOUSE_CLIENT --query="INSERT INTO test_01037.points FORMAT TSV" --max_insert_block_size=100000 < "${CURDIR}/01037_point_data"
rm ${CURDIR}/01037_point_data
$CLICKHOUSE_CLIENT --query="DROP TABLE IF EXISTS test_01037.polygons_array;"
$CLICKHOUSE_CLIENT -n --query="
DROP TABLE IF EXISTS test_01037.polygons_array;
$CLICKHOUSE_CLIENT --query="
CREATE TABLE test_01037.polygons_array
(
key Array(Array(Array(Array(Float64)))),
@ -37,11 +36,13 @@ $CLICKHOUSE_CLIENT --query="INSERT INTO test_01037.polygons_array FORMAT JSONEac
rm ${CURDIR}/01037_polygon_data
$CLICKHOUSE_CLIENT --query="DROP DICTIONARY IF EXISTS test_01037.dict_array;"
for type in ${SearchTypes[@]};
do
do
outputFile="${TMP_DIR}/results${type}.out"
$CLICKHOUSE_CLIENT -n --query="
DROP DICTIONARY IF EXISTS test_01037.dict_array;
CREATE DICTIONARY test_01037.dict_array
(
key Array(Array(Array(Array(Float64)))),
@ -51,19 +52,16 @@ do
PRIMARY KEY key
SOURCE(CLICKHOUSE(HOST 'localhost' PORT 9000 USER 'default' TABLE 'polygons_array' PASSWORD '' DB 'test_01037'))
LIFETIME(0)
LAYOUT($type());"
LAYOUT($type());
outputFile="${TMP_DIR}/results${type}.out"
$CLICKHOUSE_CLIENT -n --query="
select 'dictGet', 'test_01037.dict_array' as dict_name, tuple(x, y) as key,
dictGet(dict_name, 'value', key) from test_01037.points order by x, y;
" > $outputFile
diff -q "${CURDIR}/01037_polygon_dicts_correctness_fast.ans" "$outputFile"
$CLICKHOUSE_CLIENT --query="DROP DICTIONARY test_01037.dict_array;"
done
$CLICKHOUSE_CLIENT --query="DROP TABLE test_01037.points;"
$CLICKHOUSE_CLIENT --query="DROP DATABASE test_01037;"
$CLICKHOUSE_CLIENT -n --query="
DROP TABLE test_01037.points;
DROP DATABASE test_01037;
"

View File

@ -5,55 +5,58 @@ CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
TMP_DIR="/tmp"
$CLICKHOUSE_CLIENT --query="DROP DATABASE IF EXISTS test_01037;"
$CLICKHOUSE_CLIENT -n --query="
DROP DATABASE IF EXISTS test_01037;
$CLICKHOUSE_CLIENT --query="CREATE DATABASE test_01037 Engine = Ordinary;"
CREATE DATABASE test_01037 Engine = Ordinary;
$CLICKHOUSE_CLIENT --query="DROP TABLE IF EXISTS test_01037.polygons_array;"
DROP TABLE IF EXISTS test_01037.polygons_array;
$CLICKHOUSE_CLIENT --query="CREATE TABLE test_01037.polygons_array (key Array(Array(Array(Array(Float64)))), name String, value UInt64) ENGINE = Memory;"
$CLICKHOUSE_CLIENT --query="INSERT INTO test_01037.polygons_array VALUES ([[[[1, 3], [1, 1], [3, 1], [3, -1], [1, -1], [1, -3], [-1, -3], [-1, -1], [-3, -1], [-3, 1], [-1, 1], [-1, 3]]], [[[5, 5], [5, 1], [7, 1], [7, 7], [1, 7], [1, 5]]]], 'Click', 42);"
$CLICKHOUSE_CLIENT --query="INSERT INTO test_01037.polygons_array VALUES ([[[[5, 5], [5, -5], [-5, -5], [-5, 5]], [[1, 3], [1, 1], [3, 1], [3, -1], [1, -1], [1, -3], [-1, -3], [-1, -1], [-3, -1], [-3, 1], [-1, 1], [-1, 3]]]], 'House', 314159);"
$CLICKHOUSE_CLIENT --query="INSERT INTO test_01037.polygons_array VALUES ([[[[3, 1], [0, 1], [0, -1], [3, -1]]]], 'Click East', 421);"
$CLICKHOUSE_CLIENT --query="INSERT INTO test_01037.polygons_array VALUES ([[[[-1, 1], [1, 1], [1, 3], [-1, 3]]]], 'Click North', 422);"
$CLICKHOUSE_CLIENT --query="INSERT INTO test_01037.polygons_array VALUES ([[[[-3, 1], [-3, -1], [0, -1], [0, 1]]]], 'Click South', 423);"
$CLICKHOUSE_CLIENT --query="INSERT INTO test_01037.polygons_array VALUES ([[[[-1, -1], [1, -1], [1, -3], [-1, -3]]]], 'Click West', 424);"
CREATE TABLE test_01037.polygons_array (key Array(Array(Array(Array(Float64)))), name String, value UInt64) ENGINE = Memory;
INSERT INTO test_01037.polygons_array VALUES ([[[[1, 3], [1, 1], [3, 1], [3, -1], [1, -1], [1, -3], [-1, -3], [-1, -1], [-3, -1], [-3, 1], [-1, 1], [-1, 3]]], [[[5, 5], [5, 1], [7, 1], [7, 7], [1, 7], [1, 5]]]], 'Click', 42);
INSERT INTO test_01037.polygons_array VALUES ([[[[5, 5], [5, -5], [-5, -5], [-5, 5]], [[1, 3], [1, 1], [3, 1], [3, -1], [1, -1], [1, -3], [-1, -3], [-1, -1], [-3, -1], [-3, 1], [-1, 1], [-1, 3]]]], 'House', 314159);
INSERT INTO test_01037.polygons_array VALUES ([[[[3, 1], [0, 1], [0, -1], [3, -1]]]], 'Click East', 421);
INSERT INTO test_01037.polygons_array VALUES ([[[[-1, 1], [1, 1], [1, 3], [-1, 3]]]], 'Click North', 422);
INSERT INTO test_01037.polygons_array VALUES ([[[[-3, 1], [-3, -1], [0, -1], [0, 1]]]], 'Click South', 423);
INSERT INTO test_01037.polygons_array VALUES ([[[[-1, -1], [1, -1], [1, -3], [-1, -3]]]], 'Click West', 424);
$CLICKHOUSE_CLIENT --query="DROP TABLE IF EXISTS test_01037.polygons_tuple;"
DROP TABLE IF EXISTS test_01037.polygons_tuple;
$CLICKHOUSE_CLIENT --query="CREATE TABLE test_01037.polygons_tuple (key Array(Array(Array(Tuple(Float64, Float64)))), name String, value UInt64) ENGINE = Memory;"
$CLICKHOUSE_CLIENT --query="INSERT INTO test_01037.polygons_tuple VALUES ([[[(1, 3), (1, 1), (3, 1), (3, -1), (1, -1), (1, -3), (-1, -3), (-1, -1), (-3, -1), (-3, 1), (-1, 1), (-1, 3)]], [[(5, 5), (5, 1), (7, 1), (7, 7), (1, 7), (1, 5)]]], 'Click', 42);"
$CLICKHOUSE_CLIENT --query="INSERT INTO test_01037.polygons_tuple VALUES ([[[(5, 5), (5, -5), (-5, -5), (-5, 5)], [(1, 3), (1, 1), (3, 1), (3, -1), (1, -1), (1, -3), (-1, -3), (-1, -1), (-3, -1), (-3, 1), (-1, 1), (-1, 3)]]], 'House', 314159);"
$CLICKHOUSE_CLIENT --query="INSERT INTO test_01037.polygons_tuple VALUES ([[[(3, 1), (0, 1), (0, -1), (3, -1)]]], 'Click East', 421);"
$CLICKHOUSE_CLIENT --query="INSERT INTO test_01037.polygons_tuple VALUES ([[[(-1, 1), (1, 1), (1, 3), (-1, 3)]]], 'Click North', 422);"
$CLICKHOUSE_CLIENT --query="INSERT INTO test_01037.polygons_tuple VALUES ([[[(-3, 1), (-3, -1), (0, -1), (0, 1)]]], 'Click South', 423);"
$CLICKHOUSE_CLIENT --query="INSERT INTO test_01037.polygons_tuple VALUES ([[[(-1, -1), (1, -1), (1, -3), (-1, -3)]]], 'Click West', 424);"
CREATE TABLE test_01037.polygons_tuple (key Array(Array(Array(Tuple(Float64, Float64)))), name String, value UInt64) ENGINE = Memory;
INSERT INTO test_01037.polygons_tuple VALUES ([[[(1, 3), (1, 1), (3, 1), (3, -1), (1, -1), (1, -3), (-1, -3), (-1, -1), (-3, -1), (-3, 1), (-1, 1), (-1, 3)]], [[(5, 5), (5, 1), (7, 1), (7, 7), (1, 7), (1, 5)]]], 'Click', 42);
INSERT INTO test_01037.polygons_tuple VALUES ([[[(5, 5), (5, -5), (-5, -5), (-5, 5)], [(1, 3), (1, 1), (3, 1), (3, -1), (1, -1), (1, -3), (-1, -3), (-1, -1), (-3, -1), (-3, 1), (-1, 1), (-1, 3)]]], 'House', 314159);
INSERT INTO test_01037.polygons_tuple VALUES ([[[(3, 1), (0, 1), (0, -1), (3, -1)]]], 'Click East', 421);
INSERT INTO test_01037.polygons_tuple VALUES ([[[(-1, 1), (1, 1), (1, 3), (-1, 3)]]], 'Click North', 422);
INSERT INTO test_01037.polygons_tuple VALUES ([[[(-3, 1), (-3, -1), (0, -1), (0, 1)]]], 'Click South', 423);
INSERT INTO test_01037.polygons_tuple VALUES ([[[(-1, -1), (1, -1), (1, -3), (-1, -3)]]], 'Click West', 424);
$CLICKHOUSE_CLIENT --query="DROP TABLE IF EXISTS test_01037.points;"
DROP TABLE IF EXISTS test_01037.points;
$CLICKHOUSE_CLIENT --query="CREATE TABLE test_01037.points (x Float64, y Float64, def_i UInt64, def_s String) ENGINE = Memory;"
$CLICKHOUSE_CLIENT --query="INSERT INTO test_01037.points VALUES (0.1, 0.0, 112, 'aax');"
$CLICKHOUSE_CLIENT --query="INSERT INTO test_01037.points VALUES (-0.1, 0.0, 113, 'aay');"
$CLICKHOUSE_CLIENT --query="INSERT INTO test_01037.points VALUES (0.0, 1.1, 114, 'aaz');"
$CLICKHOUSE_CLIENT --query="INSERT INTO test_01037.points VALUES (0.0, -1.1, 115, 'aat');"
$CLICKHOUSE_CLIENT --query="INSERT INTO test_01037.points VALUES (3.0, 3.0, 22, 'bb');"
$CLICKHOUSE_CLIENT --query="INSERT INTO test_01037.points VALUES (5.0, 6.0, 33, 'cc');"
$CLICKHOUSE_CLIENT --query="INSERT INTO test_01037.points VALUES (-100.0, -42.0, 44, 'dd');"
$CLICKHOUSE_CLIENT --query="INSERT INTO test_01037.points VALUES (7.01, 7.01, 55, 'ee');"
$CLICKHOUSE_CLIENT --query="INSERT INTO test_01037.points VALUES (0.99, 2.99, 66, 'ee');"
$CLICKHOUSE_CLIENT --query="INSERT INTO test_01037.points VALUES (1.0, 0.0, 771, 'ffa');"
$CLICKHOUSE_CLIENT --query="INSERT INTO test_01037.points VALUES (-1.0, 0.0, 772, 'ffb');"
$CLICKHOUSE_CLIENT --query="INSERT INTO test_01037.points VALUES (0.0, 2.0, 773, 'ffc');"
$CLICKHOUSE_CLIENT --query="INSERT INTO test_01037.points VALUES (0.0, -2.0, 774, 'ffd');"
CREATE TABLE test_01037.points (x Float64, y Float64, def_i UInt64, def_s String) ENGINE = Memory;
INSERT INTO test_01037.points VALUES (0.1, 0.0, 112, 'aax');
INSERT INTO test_01037.points VALUES (-0.1, 0.0, 113, 'aay');
INSERT INTO test_01037.points VALUES (0.0, 1.1, 114, 'aaz');
INSERT INTO test_01037.points VALUES (0.0, -1.1, 115, 'aat');
INSERT INTO test_01037.points VALUES (3.0, 3.0, 22, 'bb');
INSERT INTO test_01037.points VALUES (5.0, 6.0, 33, 'cc');
INSERT INTO test_01037.points VALUES (-100.0, -42.0, 44, 'dd');
INSERT INTO test_01037.points VALUES (7.01, 7.01, 55, 'ee');
INSERT INTO test_01037.points VALUES (0.99, 2.99, 66, 'ee');
INSERT INTO test_01037.points VALUES (1.0, 0.0, 771, 'ffa');
INSERT INTO test_01037.points VALUES (-1.0, 0.0, 772, 'ffb');
INSERT INTO test_01037.points VALUES (0.0, 2.0, 773, 'ffc');
INSERT INTO test_01037.points VALUES (0.0, -2.0, 774, 'ffd');
"
declare -a SearchTypes=("POLYGON" "POLYGON_INDEX_EACH" "POLYGON_INDEX_CELL")
for type in ${SearchTypes[@]};
do
$CLICKHOUSE_CLIENT --query="DROP DICTIONARY IF EXISTS test_01037.dict_array;"
outputFile="${TMP_DIR}/results${type}.out"
$CLICKHOUSE_CLIENT -n --query="
DROP DICTIONARY IF EXISTS test_01037.dict_array;
CREATE DICTIONARY test_01037.dict_array
(
key Array(Array(Array(Array(Float64)))),
@ -64,11 +67,9 @@ do
SOURCE(CLICKHOUSE(HOST 'localhost' PORT 9000 USER 'default' TABLE 'polygons_array' PASSWORD '' DB 'test_01037'))
LIFETIME(0)
LAYOUT($type());
"
$CLICKHOUSE_CLIENT --query="DROP DICTIONARY IF EXISTS test_01037.dict_tuple;"
DROP DICTIONARY IF EXISTS test_01037.dict_tuple;
$CLICKHOUSE_CLIENT -n --query="
CREATE DICTIONARY test_01037.dict_tuple
(
key Array(Array(Array(Tuple(Float64, Float64)))),
@ -79,57 +80,39 @@ do
SOURCE(CLICKHOUSE(HOST 'localhost' PORT 9000 USER 'default' TABLE 'polygons_tuple' PASSWORD '' DB 'test_01037'))
LIFETIME(0)
LAYOUT($type());
"
outputFile="${TMP_DIR}/results${type}.out"
$CLICKHOUSE_CLIENT -n --query="
select 'dictGet', 'test_01037.dict_array' as dict_name, tuple(x, y) as key,
dictGet(dict_name, 'name', key),
dictGet(dict_name, 'value', key) from test_01037.points order by x, y;
" > $outputFile
$CLICKHOUSE_CLIENT -n --query="
select 'dictGetOrDefault', 'test_01037.dict_array' as dict_name, tuple(x, y) as key,
dictGetOrDefault(dict_name, 'name', key, 'www'),
dictGetOrDefault(dict_name, 'value', key, toUInt64(1234)) from test_01037.points order by x, y;
" >> $outputFile
$CLICKHOUSE_CLIENT -n --query="
select 'dictGetOrDefault', 'test_01037.dict_array' as dict_name, tuple(x, y) as key,
dictGetOrDefault(dict_name, 'name', key, def_s),
dictGetOrDefault(dict_name, 'value', key, def_i) from test_01037.points order by x, y;
" >> $outputFile
$CLICKHOUSE_CLIENT -n --query="
select 'dictGet', 'test_01037.dict_tuple' as dict_name, tuple(x, y) as key,
dictGet(dict_name, 'name', key),
dictGet(dict_name, 'value', key) from test_01037.points order by x, y;
" >> $outputFile
$CLICKHOUSE_CLIENT -n --query="
select 'dictGetOrDefault', 'test_01037.dict_tuple' as dict_name, tuple(x, y) as key,
dictGetOrDefault(dict_name, 'name', key, 'www'),
dictGetOrDefault(dict_name, 'value', key, toUInt64(1234)) from test_01037.points order by x, y;
" >> $outputFile
$CLICKHOUSE_CLIENT -n --query="
select 'dictGetOrDefault', 'test_01037.dict_tuple' as dict_name, tuple(x, y) as key,
dictGetOrDefault(dict_name, 'name', key, def_s),
dictGetOrDefault(dict_name, 'value', key, def_i) from test_01037.points order by x, y;
" >> $outputFile
$CLICKHOUSE_CLIENT --query="
select 'dictHas', 'test_01037.dict_array' as dict_name, tuple(x, y) as key,
dictHas(dict_name, key) from test_01037.points order by x, y;
" >> $outputFile
$CLICKHOUSE_CLIENT --query="
select 'dictHas', 'test_01037.dict_tuple' as dict_name, tuple(x, y) as key,
dictHas(dict_name, key) from test_01037.points order by x, y;
" >> $outputFile
" > $outputFile
diff -q "${CURDIR}/01037_polygon_dicts_simple_functions.ans" "$outputFile"
done
$CLICKHOUSE_CLIENT --query="DROP DICTIONARY test_01037.dict_array;"
$CLICKHOUSE_CLIENT --query="DROP DICTIONARY test_01037.dict_tuple;"
$CLICKHOUSE_CLIENT --query="DROP TABLE test_01037.polygons_array;"
$CLICKHOUSE_CLIENT --query="DROP TABLE test_01037.polygons_tuple;"
$CLICKHOUSE_CLIENT --query="DROP TABLE test_01037.points;"
$CLICKHOUSE_CLIENT --query="DROP DATABASE test_01037;"
$CLICKHOUSE_CLIENT -n --query="
DROP DICTIONARY test_01037.dict_array;
DROP DICTIONARY test_01037.dict_tuple;
DROP TABLE test_01037.polygons_array;
DROP TABLE test_01037.polygons_tuple;
DROP TABLE test_01037.points;
DROP DATABASE test_01037;
"