mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 07:31:57 +00:00
Merge pull request #19015 from nikitamikhaylov/defaults-for-file-engine
Added tests for defaults in URL and File engine
This commit is contained in:
commit
7d7af00afb
@ -329,6 +329,7 @@ function run_tests
|
||||
|
||||
# nc - command not found
|
||||
01601_proxy_protocol
|
||||
01622_defaults_for_url_engine
|
||||
)
|
||||
|
||||
time clickhouse-test -j 8 --order=random --no-long --testname --shard --zookeeper --skip "${TESTS_TO_SKIP[@]}" -- "$FASTTEST_FOCUS" 2>&1 | ts '%Y-%m-%d %H:%M:%S' | tee "$FASTTEST_OUTPUT/test_log.txt"
|
||||
|
@ -0,0 +1 @@
|
||||
1 7 8
|
@ -0,0 +1,7 @@
|
||||
insert into table function file("data1622.json", "TSV", "value String") VALUES ('{"a":1}');
|
||||
drop table if exists json;
|
||||
create table json(a int, b int default 7, c default a + b) engine File(JSONEachRow, 'data1622.json');
|
||||
set input_format_defaults_for_omitted_fields = 1;
|
||||
select * from json;
|
||||
truncate table json;
|
||||
drop table if exists json;
|
@ -0,0 +1 @@
|
||||
Ok
|
37
tests/queries/0_stateless/01622_defaults_for_url_engine.sh
Executable file
37
tests/queries/0_stateless/01622_defaults_for_url_engine.sh
Executable file
@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
# shellcheck source=../shell_config.sh
|
||||
. "$CURDIR"/../shell_config.sh
|
||||
|
||||
|
||||
PORT="$(($RANDOM%63000+2001))"
|
||||
|
||||
TEMP_FILE="$CURDIR/01622_defaults_for_url_engine.tmp"
|
||||
|
||||
function thread1
|
||||
{
|
||||
while true; do
|
||||
echo -e "HTTP/1.1 200 OK\n\n{\"a\": 1}" | nc -l -p $1 -q 1;
|
||||
done
|
||||
}
|
||||
|
||||
function thread2
|
||||
{
|
||||
while true; do
|
||||
$CLICKHOUSE_CLIENT --input_format_defaults_for_omitted_fields=1 -q "SELECT * FROM url('http://127.0.0.1:$1/', JSONEachRow, 'a int, b int default 7, c default a + b') format Values"
|
||||
done
|
||||
}
|
||||
|
||||
# https://stackoverflow.com/questions/9954794/execute-a-shell-function-with-timeout
|
||||
export -f thread1;
|
||||
export -f thread2;
|
||||
|
||||
TIMEOUT=5
|
||||
|
||||
timeout $TIMEOUT bash -c "thread1 $PORT" > /dev/null 2>&1 &
|
||||
timeout $TIMEOUT bash -c "thread2 $PORT" 2> /dev/null > $TEMP_FILE &
|
||||
|
||||
wait
|
||||
|
||||
grep -q '(1,7,8)' $TEMP_FILE && echo "Ok"
|
Loading…
Reference in New Issue
Block a user