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
|
|
|
|
|
|
|
|
SAMPLE_FILE="$CURDIR/01941_sample_data.csv"
|
|
|
|
|
2021-07-13 13:49:29 +00:00
|
|
|
set -e
|
|
|
|
|
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-13 13:49:29 +00:00
|
|
|
tpipe=$(mktemp -u)
|
|
|
|
mkfifo "$tpipe"
|
2021-07-09 13:15:16 +00:00
|
|
|
echo "$SAMPLE_FILE" > /tmp/pipe &
|
2021-07-13 13:49:29 +00:00
|
|
|
${CLICKHOUSE_LOCAL} --structure 'key String' -q 'select * from table; select * from table;' --file /tmp/pipe
|
|
|
|
|
2021-07-09 13:15:16 +00:00
|
|
|
|
2021-07-14 07:50:52 +00:00
|
|
|
rm "$SAMPLE_FILE"
|
2021-07-09 13:15:16 +00:00
|
|
|
|