ClickHouse/tests/queries/0_stateless/00565_enum_order.sh

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

60 lines
2.0 KiB
Bash
Raw Normal View History

2018-02-05 18:15:47 +00:00
#!/usr/bin/env bash
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
2020-12-28 11:46:53 +00:00
# shellcheck source=../shell_config.sh
2020-08-01 00:51:12 +00:00
. "$CURDIR"/../shell_config.sh
2018-02-05 18:15:47 +00:00
set -e -o pipefail
$CLICKHOUSE_CLIENT <<"EOF"
DROP TABLE IF EXISTS `test_log`
2018-02-05 18:15:47 +00:00
EOF
2022-06-23 10:58:34 +00:00
$CLICKHOUSE_CLIENT --allow_deprecated_syntax_for_merge_tree=1 <<"EOF"
CREATE TABLE `test_log` (
2018-02-05 18:15:47 +00:00
date Date,
datetime DateTime,
path String,
gtid String,
query_serial UInt32,
row_serial UInt32,
reqid Int64,
method String,
service String,
db String,
type String,
operation Enum8('INSERT'=1, 'UPDATE'=2, 'DELETE'=3),
old_fields Nested(name String, value String, is_null Enum8('true'=1, 'false'=0)),
new_fields Nested(name String, value String, is_null Enum8('true'=1, 'false'=0)),
record_source_type Int8,
record_source_timestamp DateTime,
deleted Enum8('true'=1, 'false'=0)
) ENGINE = MergeTree(
date,
(date, path, gtid, query_serial, row_serial),
1024
)
EOF
DATA='2018-01-01\t2018-01-01 03:00:00\tclient:1-\tserveruuid:0\t0\t0\t0\t\t\ttest\ttest\tINSERT\t[]\t[]\t[]\t[]\t[]\t[]\t1\t2018-02-02 15:54:10\tfalse\n'
2020-08-01 01:14:25 +00:00
QUERY='INSERT INTO "test_log"("date", "datetime", "path", "gtid", "query_serial", "row_serial",
"reqid", "method", "service", "db", "type", "operation", "old_fields"."name",
"old_fields"."value", "old_fields"."is_null", "new_fields"."name", "new_fields"."value",
"new_fields"."is_null", "record_source_type", "record_source_timestamp", "deleted") FORMAT TabSeparated'
2018-02-05 18:15:47 +00:00
QUERY="$(tr -d '\n' <<<"$QUERY")"
echo "$QUERY"
2020-10-02 16:54:07 +00:00
URL=$(python3 -c 'import urllib.parse; print("'"${CLICKHOUSE_URL}"'&query=" + urllib.parse.quote('"'''$QUERY'''"'))')
2018-02-05 18:15:47 +00:00
set +e
2020-08-01 00:40:56 +00:00
for _ in 1 2 3; do
2018-02-05 18:15:47 +00:00
echo run by native protocol
2020-08-01 01:14:25 +00:00
echo -ne "$DATA" | $CLICKHOUSE_CLIENT --query "$QUERY"
2018-02-05 18:15:47 +00:00
echo run by http protocol
2020-08-01 01:14:25 +00:00
echo -ne "$DATA" | $CLICKHOUSE_CURL -sS -X POST --data-binary @- "$URL"
2018-02-05 18:15:47 +00:00
done
echo 'Count:'
$CLICKHOUSE_CLIENT --query 'select count() from test_log'
$CLICKHOUSE_CLIENT --query 'DROP TABLE test_log'