find method to get user_files_path

This commit is contained in:
keenwolf 2021-01-28 19:13:32 +08:00
parent a671ebf3e9
commit 5d774c0cd9
2 changed files with 15 additions and 6 deletions

View File

@ -1,3 +1,15 @@
aaaaaaaaa bbbbbbbbb
:0
:0
:0
ccccccccc aaaaaaaaa bbbbbbbbb
ccccccccc aaaaaaaaa bbbbbbbbb
:0
:107
:79
:35
:35
:35
699415
aaaaaaaaa bbbbbbbbb
ccccccccc aaaaaaaaa bbbbbbbbb

View File

@ -6,9 +6,9 @@ CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
. "$CURDIR"/../shell_config.sh
# Data preparation.
# When run with client mode on different machine to the server, the data-file creation maybe implemented in SQL. Now we just make it simple
user_files_path=$(clickhouse-client --query "select data_path from system.databases where name='default'" | sed -En 's/data\/default/user_files/p')
#user_files_path=$(grep user_files_path ${CLICKHOUSE_CONFIG} | awk '{match($0,"<user_files_path>(.*)</user_files_path>",path); print path[1]}')
# 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')"
user_files_path=$(clickhouse-client --query "select _path,_file from file('nonexist.txt', 'CSV', 'val1 char')" 2>&1 |grep Exception | awk '{match($0,"File (.*)/nonexist.txt",path); print path[1]}')
mkdir -p ${user_files_path}/
echo -n aaaaaaaaa > ${user_files_path}/a.txt
echo -n bbbbbbbbb > ${user_files_path}/b.txt
@ -16,8 +16,6 @@ echo -n ccccccccc > ${user_files_path}/c.txt
echo -n ccccccccc > /tmp/c.txt
mkdir -p ${user_files_path}/dir
# Skip the client test part, for being unable to get the correct user_files_path
if false; then
### 1st TEST in CLIENT mode.
${CLICKHOUSE_CLIENT} --query "drop table if exists data;"
@ -43,7 +41,6 @@ echo "clickhouse-client --query "'"select file('"'/tmp/c.txt'), file('${user_fil
echo "clickhouse-client --query "'"select file('"'${user_files_path}/../../../../tmp/c.txt'), file('b.txt')"'";echo :$?' | bash 2>/dev/null
echo "clickhouse-client --query "'"select file('"'../../../../a.txt'), file('${user_files_path}/b.txt')"'";echo :$?' | bash 2>/dev/null
fi
### 2nd TEST in LOCAL mode.