2017-01-11 19:05:46 +00:00
#!/usr/bin/env bash
2017-11-01 11:46:58 +00:00
CURDIR = $( cd " $( dirname " ${ BASH_SOURCE [0] } " ) " && pwd )
. $CURDIR /../shell_config.sh
2017-01-11 19:05:46 +00:00
function perform( )
{
2017-04-05 11:52:23 +00:00
local test_id = $1
local query = $2
echo " performing test: $test_id "
2017-11-01 11:46:58 +00:00
${ CLICKHOUSE_CLIENT } --query " $query " 2>/dev/null
2017-04-05 11:52:23 +00:00
if [ " $? " -eq 0 ] ; then
2017-12-27 15:56:42 +00:00
cat " ${ CLICKHOUSE_TMP } /test_into_outfile_ $test_id .out "
2017-04-05 11:52:23 +00:00
else
echo "query failed"
fi
2017-12-27 15:56:42 +00:00
rm -f " ${ CLICKHOUSE_TMP } /test_into_outfile_ $test_id .out "
2017-01-11 19:05:46 +00:00
}
2017-12-27 15:56:42 +00:00
perform "select" " SELECT 1, 2, 3 INTO OUTFILE ' ${ CLICKHOUSE_TMP } /test_into_outfile_select.out' "
2017-01-11 19:05:46 +00:00
2017-12-27 15:56:42 +00:00
perform "union_all" " SELECT 1, 2 UNION ALL SELECT 3, 4 INTO OUTFILE ' ${ CLICKHOUSE_TMP } /test_into_outfile_union_all.out' FORMAT TSV " | sort --numeric-sort
2017-01-11 19:05:46 +00:00
2017-12-27 15:56:42 +00:00
perform "bad_union_all" " SELECT 1, 2 INTO OUTFILE ' ${ CLICKHOUSE_TMP } /test_into_outfile_bad_union_all.out' UNION ALL SELECT 3, 4 "
2017-01-11 19:05:46 +00:00
2017-12-27 15:56:42 +00:00
perform "describe_table" " DESCRIBE TABLE system.one INTO OUTFILE ' ${ CLICKHOUSE_TMP } /test_into_outfile_describe_table.out' "
2017-01-11 19:05:46 +00:00
echo "performing test: clickhouse-local"
2018-08-23 00:14:26 +00:00
echo -e '1\t2' | ${ CLICKHOUSE_LOCAL } --structure 'col1 UInt32, col2 UInt32' --query " SELECT col1 + 1, col2 + 1 FROM table INTO OUTFILE ' ${ CLICKHOUSE_TMP } /test_into_outfile_clickhouse-local.out' "
2018-08-22 23:54:33 +00:00
err = $?
if [ " $err " -eq 0 ] ; then
2017-12-27 15:56:42 +00:00
cat " ${ CLICKHOUSE_TMP } /test_into_outfile_clickhouse-local.out "
2017-01-11 19:05:46 +00:00
else
2018-08-22 23:54:33 +00:00
echo " query failed with exit code $err "
2017-01-11 19:05:46 +00:00
fi
2017-12-27 15:56:42 +00:00
rm -f " ${ CLICKHOUSE_TMP } /test_into_outfile_clickhouse-local.out "
2017-01-11 19:05:46 +00:00
echo "performing test: http"
2017-12-27 15:56:42 +00:00
echo " SELECT 1, 2 INTO OUTFILE ' ${ CLICKHOUSE_TMP } /test_into_outfile_http.out' " | ${ CLICKHOUSE_CURL } -s " ${ CLICKHOUSE_URL } " -d @- --fail || echo "query failed"