2016-12-21 20:04:27 +00:00
#!/usr/bin/env bash
2016-11-11 17:01:02 +00:00
set -e
2017-11-01 11:46:58 +00:00
CURDIR = $( cd " $( dirname " ${ BASH_SOURCE [0] } " ) " && pwd )
. $CURDIR /../shell_config.sh
2016-11-11 17:01:02 +00:00
TABLE_HASH = "cityHash64(groupArray(cityHash64(*)))"
function pack_unpack_compare( )
{
2019-04-16 14:13:13 +00:00
local buf_file = " ${ CLICKHOUSE_TMP } /buf.'. $3 "
2016-11-11 17:01:02 +00:00
2019-04-16 14:13:13 +00:00
${ CLICKHOUSE_CLIENT } --query "DROP TABLE IF EXISTS buf"
${ CLICKHOUSE_CLIENT } --query "DROP TABLE IF EXISTS buf_file"
2016-11-11 17:01:02 +00:00
2019-04-16 14:13:13 +00:00
${ CLICKHOUSE_CLIENT } --query " CREATE TABLE buf ENGINE = Memory AS $1 "
local res_orig = $( ${ CLICKHOUSE_CLIENT } --max_threads= 1 --query " SELECT $TABLE_HASH FROM buf " )
2016-11-14 21:58:17 +00:00
2019-04-16 14:13:13 +00:00
${ CLICKHOUSE_CLIENT } --max_threads= 1 --query " CREATE TABLE buf_file ENGINE = File( $3 ) AS SELECT * FROM buf "
local res_db_file = $( ${ CLICKHOUSE_CLIENT } --max_threads= 1 --query " SELECT $TABLE_HASH FROM buf_file " )
2016-11-11 17:01:02 +00:00
2019-04-16 14:13:13 +00:00
${ CLICKHOUSE_CLIENT } --max_threads= 1 --query " SELECT * FROM buf FORMAT $3 " > " $buf_file "
2018-04-20 19:31:19 +00:00
local res_ch_local1 = $( ${ CLICKHOUSE_LOCAL } --structure " $2 " --file " $buf_file " --table "my super table" --input-format " $3 " --output-format TabSeparated --query " SELECT $TABLE_HASH FROM \`my super table\` " )
local res_ch_local2 = $( ${ CLICKHOUSE_LOCAL } --structure " $2 " --table "my super table" --input-format " $3 " --output-format TabSeparated --query " SELECT $TABLE_HASH FROM \`my super table\` " < " $buf_file " )
2016-11-11 17:01:02 +00:00
2019-04-16 14:13:13 +00:00
${ CLICKHOUSE_CLIENT } --query "DROP TABLE IF EXISTS buf"
${ CLICKHOUSE_CLIENT } --query "DROP TABLE IF EXISTS buf_file"
2018-03-07 13:11:25 +00:00
rm -f " $buf_file " stderr
2016-11-11 17:01:02 +00:00
2017-04-05 11:52:23 +00:00
echo $(( res_orig - res_db_file)) $(( res_orig - res_ch_local1)) $(( res_orig - res_ch_local2))
2016-11-11 17:01:02 +00:00
}
2016-11-14 21:58:17 +00:00
pack_unpack_compare "SELECT number FROM system.numbers LIMIT 10000" "number UInt64" "TabSeparated"
2016-11-11 17:01:02 +00:00
pack_unpack_compare "SELECT number FROM system.numbers LIMIT 10000" "number UInt64" "Native"
pack_unpack_compare "SELECT number FROM system.numbers LIMIT 10000" "number UInt64" "JSONEachRow"
echo
pack_unpack_compare "SELECT name, is_aggregate FROM system.functions" "name String, is_aggregate UInt8" "TabSeparated"
pack_unpack_compare "SELECT name, is_aggregate FROM system.functions" "name String, is_aggregate UInt8" "Native"
pack_unpack_compare "SELECT name, is_aggregate FROM system.functions" "name String, is_aggregate UInt8" "TSKV"
2017-06-15 20:08:26 +00:00
echo
2018-04-20 15:32:40 +00:00
# Check settings are passed correctly
2018-04-20 19:31:19 +00:00
${ CLICKHOUSE_LOCAL } --max_rows_in_distinct= 33 -q "SELECT name, value FROM system.settings WHERE name = 'max_rows_in_distinct'"
${ CLICKHOUSE_LOCAL } -q "SET max_rows_in_distinct=33; SELECT name, value FROM system.settings WHERE name = 'max_rows_in_distinct'"
${ CLICKHOUSE_LOCAL } --max_bytes_before_external_group_by= 1 --max_block_size= 10 -q "SELECT sum(ignore(*)) FROM (SELECT number, count() FROM numbers(1000) GROUP BY number)"
2018-04-20 15:32:40 +00:00
echo
2018-04-20 19:31:19 +00:00
# Check exta options
2018-08-23 01:35:46 +00:00
( ${ CLICKHOUSE_LOCAL } --ignore-error --echo -q "SELECT nothing_to_do();SELECT 42;" 2>/dev/null && echo "Wrong RC" ) || true
2018-04-20 19:31:19 +00:00
echo
${ CLICKHOUSE_LOCAL } -q " CREATE TABLE sophisticated_default
2017-06-15 20:08:26 +00:00
(
a UInt8 DEFAULT
(
SELECT number FROM system.numbers LIMIT 3,1
) ,
b UInt8 ALIAS
(
SELECT dummy+9 FROM system.one
) ,
c UInt8
2018-01-15 14:58:21 +00:00
) ENGINE = Memory; SELECT count( ) FROM system.tables WHERE name = 'sophisticated_default' ; "
# Help is not skipped
2018-04-24 10:40:03 +00:00
[ [ ` ${ CLICKHOUSE_LOCAL } --help | wc -l` > 100 ] ]