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-17 10:58:40 +00:00
|
|
|
SAMPLE_FILE=$(mktemp 01947_multiple_pipe_read_sample_data_XXXXXX.csv)
|
2021-07-13 13:49:29 +00:00
|
|
|
|
2021-07-09 13:15:16 +00:00
|
|
|
echo 'File generated:'
|
2021-07-24 16:50:03 +00:00
|
|
|
${CLICKHOUSE_LOCAL} -q "SELECT number AS x, if(number in (4,6), 'AAA', 'BBB') AS s from numbers(7)" > "$SAMPLE_FILE"
|
2021-07-09 13:15:16 +00:00
|
|
|
cat "$SAMPLE_FILE"
|
|
|
|
|
|
|
|
echo '******************'
|
2021-07-24 16:50:03 +00:00
|
|
|
echo 'Read twice from a regular file'
|
|
|
|
${CLICKHOUSE_LOCAL} --structure 'x UInt64, s String' -q 'select * from table; select * from table;' --file "$SAMPLE_FILE"
|
|
|
|
echo '---'
|
|
|
|
${CLICKHOUSE_LOCAL} --structure 'x UInt64, s String' -q 'select * from table WHERE x IN (select x from table);' --file "$SAMPLE_FILE"
|
|
|
|
echo '---'
|
|
|
|
${CLICKHOUSE_LOCAL} --structure 'x UInt64, s String' -q 'select * from table UNION ALL select * from table;' --file "$SAMPLE_FILE"
|
2021-07-09 13:15:16 +00:00
|
|
|
|
|
|
|
echo '******************'
|
2021-07-24 16:50:03 +00:00
|
|
|
echo 'Read twice from file descriptor that corresponds to a regular file'
|
|
|
|
${CLICKHOUSE_LOCAL} --structure 'x UInt64, s String' -q 'select * from table; select * from table;' < "$SAMPLE_FILE"
|
|
|
|
echo '---'
|
|
|
|
${CLICKHOUSE_LOCAL} --structure 'x UInt64, s String' -q 'select * from table WHERE x IN (select x from table);' < "$SAMPLE_FILE"
|
|
|
|
echo '---'
|
|
|
|
${CLICKHOUSE_LOCAL} --structure 'x UInt64, s String' -q 'select * from table UNION ALL select * from table;' < "$SAMPLE_FILE"
|
2021-07-09 13:15:16 +00:00
|
|
|
|
2021-07-24 16:50:03 +00:00
|
|
|
rm "$SAMPLE_FILE"
|