2021-07-09 13:15:16 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|
|
|
# shellcheck source=../shell_config.sh
|
|
|
|
. "$CURDIR"/../shell_config.sh
|
|
|
|
|
2021-07-15 14:47:03 +00:00
|
|
|
SAMPLE_FILE="$CURDIR/01947_sample_data.csv"
|
|
|
|
STD_ERROR_CAPTURED="$CURDIR/01947_std_error_captured.log"
|
2021-07-13 13:49:29 +00:00
|
|
|
|
2021-07-09 13:15:16 +00:00
|
|
|
echo 'File generated:'
|
2021-07-13 11:08:51 +00:00
|
|
|
${CLICKHOUSE_LOCAL} -q "SELECT number, if(number in (4,6), 'AAA', 'BBB') from numbers(7) FORMAT CSV" --format_csv_delimiter=, >"$SAMPLE_FILE"
|
2021-07-09 13:15:16 +00:00
|
|
|
cat "$SAMPLE_FILE"
|
|
|
|
|
|
|
|
echo '******************'
|
|
|
|
echo 'Attempt to read twice from a pipeline'
|
2021-07-13 13:49:29 +00:00
|
|
|
${CLICKHOUSE_LOCAL} --structure 'key String' -q 'select * from table; select * from table;' <<<foo
|
2021-07-09 13:15:16 +00:00
|
|
|
|
|
|
|
echo '******************'
|
|
|
|
echo 'Attempt to read twice from a regular file'
|
2021-07-13 13:49:29 +00:00
|
|
|
${CLICKHOUSE_LOCAL} --structure 'key String' -q 'select * from table; select * from table;' --file "$SAMPLE_FILE"
|
2021-07-09 13:15:16 +00:00
|
|
|
|
|
|
|
echo '******************'
|
|
|
|
echo 'Attempt to read twice from a pipe'
|
2021-07-15 08:24:45 +00:00
|
|
|
echo 1 | ${CLICKHOUSE_LOCAL} --structure "a int" --query "select a from table where a in (select a from table)" 2>"$STD_ERROR_CAPTURED"
|
|
|
|
expected_error_message='Cannot read from a pipeline twice'
|
|
|
|
cat "$STD_ERROR_CAPTURED" | grep -q "$expected_error_message" && echo "OK: stderr contains a message '$expected_error_message'" || echo "FAILED: Error message is wrong"
|
2021-07-09 13:15:16 +00:00
|
|
|
|
2021-07-15 08:24:45 +00:00
|
|
|
rm "$SAMPLE_FILE" "$STD_ERROR_CAPTURED"
|