ClickHouse/tests/queries/0_stateless/02297_regex_parsing_file_names.sh

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

41 lines
1.7 KiB
Bash
Raw Normal View History

2022-07-06 04:18:39 +00:00
#!/usr/bin/env bash
2022-07-09 02:03:27 +00:00
# Tags: no-parallel
2022-07-06 04:18:39 +00:00
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# shellcheck source=../shell_config.sh
. "$CURDIR"/../shell_config.sh
# Data preparation.
# Now we can get the user_files_path by use the table file function for trick. also we can get it by query as:
# "insert into function file('exist.txt', 'CSV', 'val1 char') values ('aaaa'); select _path from file('exist.txt', 'CSV', 'val1 char')"
CLICKHOUSE_USER_FILES_PATH=$(clickhouse-client --query "select _path, _file from file('nonexist.txt', 'CSV', 'val1 char')" 2>&1 | grep Exception | awk '{gsub("/nonexist.txt","",$9); print $9}')
mkdir -p ${CLICKHOUSE_USER_FILES_PATH}/
rm -rf ${CLICKHOUSE_USER_FILES_PATH}/file_{0..10}.csv
echo '0' > ${CLICKHOUSE_USER_FILES_PATH}/file_0.csv
echo '0' > ${CLICKHOUSE_USER_FILES_PATH}/file_1.csv
echo '0' > ${CLICKHOUSE_USER_FILES_PATH}/file_2.csv
echo '0' > ${CLICKHOUSE_USER_FILES_PATH}/file_3.csv
echo '0' > ${CLICKHOUSE_USER_FILES_PATH}/file_4.csv
echo '0' > ${CLICKHOUSE_USER_FILES_PATH}/file_5.csv
echo '0' > ${CLICKHOUSE_USER_FILES_PATH}/file_6.csv
echo '0' > ${CLICKHOUSE_USER_FILES_PATH}/file_7.csv
echo '0' > ${CLICKHOUSE_USER_FILES_PATH}/file_8.csv
echo '0' > ${CLICKHOUSE_USER_FILES_PATH}/file_9.csv
echo '0' > ${CLICKHOUSE_USER_FILES_PATH}/file_10.csv
# echo '' > ${CLICKHOUSE_USER_FILES_PATH}/file_10.csv
2022-07-06 04:18:39 +00:00
2022-07-08 04:22:00 +00:00
${CLICKHOUSE_CLIENT} -q "DROP TABLE IF EXISTS t_regex;"
2022-07-06 04:18:39 +00:00
${CLICKHOUSE_CLIENT} -q "CREATE TABLE t_regex (id UInt64) ENGINE = MergeTree() order by id;"
2022-07-06 04:18:39 +00:00
${CLICKHOUSE_CLIENT} -q "INSERT INTO t_regex SELECT * FROM file('file_{0..10}.csv','CSV');"
2022-07-08 04:22:00 +00:00
${CLICKHOUSE_CLIENT} -q "SELECT count() from t_regex;"
2022-07-06 04:18:39 +00:00
rm -rf ${CLICKHOUSE_USER_FILES_PATH}/file_{0..10}.csv;
2022-07-08 04:22:00 +00:00
${CLICKHOUSE_CLIENT} -q "DROP TABLE IF EXISTS t_regex;"