mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 01:22:04 +00:00
Merge pull request #12105 from filimonov/test_fixed_issue_10668
Test for input_format_allow_errors_num in CSV
This commit is contained in:
commit
3ea0641b5e
@ -0,0 +1,40 @@
|
|||||||
|
File generated:
|
||||||
|
0,0
|
||||||
|
1,0
|
||||||
|
2,0
|
||||||
|
3,0
|
||||||
|
4,AAAAAAA
|
||||||
|
5,0
|
||||||
|
6,AAAAAAA
|
||||||
|
******************
|
||||||
|
attempt to parse w/o flags
|
||||||
|
Return code: 117
|
||||||
|
OK: stderr contains a message 'is not like Int64'
|
||||||
|
******************
|
||||||
|
attempt to parse with input_format_allow_errors_ratio=0.1
|
||||||
|
Return code: 117
|
||||||
|
OK: stderr contains a message 'Already have 1 errors out of 5 rows, which is 0.2'
|
||||||
|
******************
|
||||||
|
attempt to parse with input_format_allow_errors_ratio=0.3
|
||||||
|
0 0
|
||||||
|
1 0
|
||||||
|
2 0
|
||||||
|
3 0
|
||||||
|
4 0
|
||||||
|
5 0
|
||||||
|
6 0
|
||||||
|
Return code: 0
|
||||||
|
******************
|
||||||
|
attempt to parse with input_format_allow_errors_num=1
|
||||||
|
Return code: 117
|
||||||
|
OK: stderr contains a message 'Already have 2 errors out of 7 rows'
|
||||||
|
******************
|
||||||
|
attempt to parse with input_format_allow_errors_num=2
|
||||||
|
0 0
|
||||||
|
1 0
|
||||||
|
2 0
|
||||||
|
3 0
|
||||||
|
4 0
|
||||||
|
5 0
|
||||||
|
6 0
|
||||||
|
Return code: 0
|
45
tests/queries/0_stateless/01355_CSV_input_format_allow_errors.sh
Executable file
45
tests/queries/0_stateless/01355_CSV_input_format_allow_errors.sh
Executable file
@ -0,0 +1,45 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||||
|
. "$CURDIR/../shell_config.sh"
|
||||||
|
|
||||||
|
SAMPLE_FILE="$CURDIR/01355_sample_data.csv"
|
||||||
|
STD_ERROR_CAPTURED="$CURDIR/01355_std_error_captured.log"
|
||||||
|
|
||||||
|
echo 'File generated:'
|
||||||
|
${CLICKHOUSE_LOCAL} -q "SELECT number, if(number in (4,6), 'AAAAAAA', '0') from numbers(7) FORMAT TSV" | tr '\t' ',' >"$SAMPLE_FILE"
|
||||||
|
cat "$SAMPLE_FILE"
|
||||||
|
|
||||||
|
echo '******************'
|
||||||
|
echo 'attempt to parse w/o flags'
|
||||||
|
cat "$SAMPLE_FILE" | clickhouse-local --input-format=CSV --structure='num1 Int64, num2 Int64' --query='SELECT * from table' 2>"$STD_ERROR_CAPTURED"
|
||||||
|
echo "Return code: $?"
|
||||||
|
expected_error_message='is not like Int64'
|
||||||
|
cat "$STD_ERROR_CAPTURED" | grep -q "$expected_error_message" && echo "OK: stderr contains a message '$expected_error_message'" || echo "FAILED: Error message is wrong"
|
||||||
|
|
||||||
|
echo '******************'
|
||||||
|
echo 'attempt to parse with input_format_allow_errors_ratio=0.1'
|
||||||
|
cat "$SAMPLE_FILE" | clickhouse-local --input-format=CSV --structure='num1 Int64, num2 Int64' --query='SELECT * from table' --input_format_allow_errors_ratio=0.1 2>"$STD_ERROR_CAPTURED"
|
||||||
|
echo "Return code: $?"
|
||||||
|
expected_error_message='Already have 1 errors out of 5 rows, which is 0.2'
|
||||||
|
cat "$STD_ERROR_CAPTURED" | grep -q "$expected_error_message" && echo "OK: stderr contains a message '$expected_error_message'" || echo "FAILED: Error message is wrong"
|
||||||
|
|
||||||
|
echo '******************'
|
||||||
|
echo 'attempt to parse with input_format_allow_errors_ratio=0.3'
|
||||||
|
cat "$SAMPLE_FILE" | clickhouse-local --input-format=CSV --structure='num1 Int64, num2 Int64' --query='SELECT * from table' --input_format_allow_errors_ratio=0.3 2>"$STD_ERROR_CAPTURED"
|
||||||
|
echo "Return code: $?"
|
||||||
|
cat "$STD_ERROR_CAPTURED"
|
||||||
|
|
||||||
|
echo '******************'
|
||||||
|
echo 'attempt to parse with input_format_allow_errors_num=1'
|
||||||
|
cat "$SAMPLE_FILE" | clickhouse-local --input-format=CSV --structure='num1 Int64, num2 Int64' --query='SELECT * from table' --input_format_allow_errors_num=1 2>"$STD_ERROR_CAPTURED"
|
||||||
|
echo "Return code: $?"
|
||||||
|
expected_error_message='Already have 2 errors out of 7 rows'
|
||||||
|
cat "$STD_ERROR_CAPTURED" | grep -q "$expected_error_message" && echo "OK: stderr contains a message '$expected_error_message'" || echo "FAILED: Error message is wrong"
|
||||||
|
|
||||||
|
echo '******************'
|
||||||
|
echo 'attempt to parse with input_format_allow_errors_num=2'
|
||||||
|
cat "$SAMPLE_FILE" | clickhouse-local --input-format=CSV --structure='num1 Int64, num2 Int64' --query='SELECT * from table' --input_format_allow_errors_num=2 2>"$STD_ERROR_CAPTURED"
|
||||||
|
echo "Return code: $?"
|
||||||
|
cat "$STD_ERROR_CAPTURED"
|
||||||
|
|
||||||
|
rm "$STD_ERROR_CAPTURED" "$SAMPLE_FILE"
|
Loading…
Reference in New Issue
Block a user