2023-06-20 22:29:46 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
# Tags: no-fasttest, use-hdfs, no-parallel
|
|
|
|
|
2023-08-04 10:41:55 +00:00
|
|
|
CLICKHOUSE_CLIENT_SERVER_LOGS_LEVEL=none
|
|
|
|
|
2023-06-20 22:29:46 +00:00
|
|
|
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|
|
|
# shellcheck source=../shell_config.sh
|
|
|
|
. "$CURDIR"/../shell_config.sh
|
|
|
|
|
|
|
|
# Prepare data
|
|
|
|
${CLICKHOUSE_CLIENT} -q "insert into table function hdfs('hdfs://localhost:12222/test_02725_1.tsv', 'TSV', 'column1 UInt32, column2 UInt32, column3 UInt32') select 1, 2, 3 settings hdfs_truncate_on_insert=1;"
|
2023-11-08 11:55:14 +00:00
|
|
|
ret=$?
|
|
|
|
if [ $ret -ne 0 ]; then
|
|
|
|
echo "Insert failed!"
|
|
|
|
exit 1
|
|
|
|
fi
|
2023-06-20 22:29:46 +00:00
|
|
|
${CLICKHOUSE_CLIENT} -q "insert into table function hdfs('hdfs://localhost:12222/test_02725_2.tsv', 'TSV', 'column1 UInt32, column2 UInt32, column3 UInt32') select 4, 5, 6 settings hdfs_truncate_on_insert=1;"
|
2023-11-08 11:55:14 +00:00
|
|
|
ret=$?
|
|
|
|
if [ $ret -ne 0 ]; then
|
|
|
|
echo "Insert failed!"
|
|
|
|
exit 1
|
|
|
|
fi
|
2023-06-20 22:29:46 +00:00
|
|
|
|
|
|
|
#################
|
|
|
|
echo "Test 1: select from hdfs database"
|
|
|
|
|
|
|
|
# Database without specific host
|
|
|
|
${CLICKHOUSE_CLIENT} --multiline --multiquery -q """
|
2023-11-08 12:31:36 +00:00
|
|
|
DROP DATABASE IF EXISTS test_hdfs_1;
|
2023-11-08 11:55:14 +00:00
|
|
|
CREATE DATABASE test_hdfs_1 ENGINE = HDFS;
|
|
|
|
USE test_hdfs_1;
|
2023-06-20 22:29:46 +00:00
|
|
|
SELECT * FROM \"hdfs://localhost:12222/test_02725_1.tsv\"
|
|
|
|
"""
|
2023-11-08 12:38:08 +00:00
|
|
|
${CLICKHOUSE_CLIENT} -q "SHOW DATABASES;" | grep test_hdfs_1
|
2023-06-20 22:29:46 +00:00
|
|
|
|
|
|
|
# Database with host
|
|
|
|
${CLICKHOUSE_CLIENT} --multiline --multiquery -q """
|
2023-11-08 12:31:36 +00:00
|
|
|
DROP DATABASE IF EXISTS test_hdfs_2;
|
2023-11-08 11:55:14 +00:00
|
|
|
CREATE DATABASE test_hdfs_2 ENGINE = HDFS('hdfs://localhost:12222');
|
|
|
|
USE test_hdfs_2;
|
2023-06-20 22:29:46 +00:00
|
|
|
SELECT * FROM \"test_02725_1.tsv\"
|
|
|
|
"""
|
2023-11-08 12:38:35 +00:00
|
|
|
${CLICKHOUSE_CLIENT} -q "SHOW DATABASES;" | grep test_hdfs_2
|
2023-06-20 22:29:46 +00:00
|
|
|
|
|
|
|
#################
|
|
|
|
echo "Test 2: check exceptions"
|
|
|
|
|
|
|
|
${CLICKHOUSE_CLIENT} --multiline --multiquery -q """
|
2023-11-08 12:31:36 +00:00
|
|
|
DROP DATABASE IF EXISTS test_hdfs_3;
|
2023-11-08 11:55:14 +00:00
|
|
|
CREATE DATABASE test_hdfs_3 ENGINE = HDFS('abacaba');
|
2023-08-04 10:41:55 +00:00
|
|
|
""" 2>&1 | tr '\n' ' ' | grep -oF "BAD_ARGUMENTS"
|
2023-06-20 22:29:46 +00:00
|
|
|
|
|
|
|
${CLICKHOUSE_CLIENT} --multiline --multiquery -q """
|
2023-11-08 12:31:36 +00:00
|
|
|
DROP DATABASE IF EXISTS test_hdfs_4;
|
2023-11-08 11:55:14 +00:00
|
|
|
CREATE DATABASE test_hdfs_4 ENGINE = HDFS;
|
|
|
|
USE test_hdfs_4;
|
2023-06-20 22:29:46 +00:00
|
|
|
SELECT * FROM \"abacaba/file.tsv\"
|
2023-08-04 10:41:55 +00:00
|
|
|
""" 2>&1 | tr '\n' ' ' | grep -oF "CANNOT_EXTRACT_TABLE_STRUCTURE"
|
2023-06-20 22:29:46 +00:00
|
|
|
|
2023-11-08 11:55:14 +00:00
|
|
|
${CLICKHOUSE_CLIENT} -q "SELECT * FROM test_hdfs_4.\`http://localhost:11111/test/a.tsv\`" 2>&1 | tr '\n' ' ' | grep -oF -e "UNKNOWN_TABLE" -e "BAD_ARGUMENTS" > /dev/null && echo "OK" || echo 'FAIL' ||:
|
2024-01-24 17:55:31 +00:00
|
|
|
${CLICKHOUSE_CLIENT} --query "SELECT * FROM test_hdfs_4.\`hdfs://localhost:12222/file.myext\`" 2>&1 | tr '\n' ' ' | grep -oF -e "UNKNOWN_TABLE" -e "CANNOT_EXTRACT_TABLE_STRUCTURE" > /dev/null && echo "OK" || echo 'FAIL' ||:
|
2023-11-08 11:55:14 +00:00
|
|
|
${CLICKHOUSE_CLIENT} --query "SELECT * FROM test_hdfs_4.\`hdfs://localhost:12222/test_02725_3.tsv\`" 2>&1 | tr '\n' ' ' | grep -oF -e "UNKNOWN_TABLE" -e "CANNOT_EXTRACT_TABLE_STRUCTURE" > /dev/null && echo "OK" || echo 'FAIL' ||:
|
2023-08-04 11:32:59 +00:00
|
|
|
|
2023-11-08 11:55:14 +00:00
|
|
|
${CLICKHOUSE_CLIENT} --query "SELECT * FROM test_hdfs_4.\`hdfs://localhost:12222\`" 2>&1 | tr '\n' ' ' | grep -oF -e "UNKNOWN_TABLE" -e "BAD_ARGUMENTS" > /dev/null && echo "OK" || echo 'FAIL' ||:
|
2023-06-20 22:29:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Cleanup
|
|
|
|
${CLICKHOUSE_CLIENT} --multiline --multiquery -q """
|
2023-11-08 11:55:14 +00:00
|
|
|
DROP DATABASE IF EXISTS test_hdfs_1;
|
|
|
|
DROP DATABASE IF EXISTS test_hdfs_2;
|
|
|
|
DROP DATABASE IF EXISTS test_hdfs_3;
|
|
|
|
DROP DATABASE IF EXISTS test_hdfs_4;
|
2023-06-30 10:58:17 +00:00
|
|
|
"""
|