mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 08:32:02 +00:00
35 lines
1.4 KiB
Bash
Executable File
35 lines
1.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|
SCHEMADIR=$CURDIR/format_schemas
|
|
# shellcheck source=../shell_config.sh
|
|
. "$CURDIR"/../shell_config.sh
|
|
|
|
set -eo pipefail
|
|
|
|
# Run the client.
|
|
$CLICKHOUSE_CLIENT --multiquery <<EOF
|
|
DROP TABLE IF EXISTS squares_protobuf_00825;
|
|
|
|
CREATE TABLE squares_protobuf_00825 (number UInt32, square UInt64) ENGINE = MergeTree ORDER BY tuple();
|
|
|
|
INSERT INTO squares_protobuf_00825 VALUES (2, 4), (0, 0), (3, 9);
|
|
|
|
SELECT * FROM squares_protobuf_00825;
|
|
EOF
|
|
|
|
BINARY_FILE_PATH=$(mktemp "$CURDIR/00825_protobuf_format_nested_optional.XXXXXX.binary")
|
|
$CLICKHOUSE_CLIENT --query "SELECT * FROM squares_protobuf_00825 FORMAT Protobuf SETTINGS format_schema = '$SCHEMADIR/00825_protobuf_format_squares:NumberAndSquare'" > "$BINARY_FILE_PATH"
|
|
|
|
# Check the output in the protobuf format
|
|
echo
|
|
$CURDIR/helpers/protobuf_length_delimited_encoder.py --decode_and_check --format_schema "$SCHEMADIR/00825_protobuf_format_squares:NumberAndSquare" --input "$BINARY_FILE_PATH"
|
|
|
|
# Check the input in the protobuf format (now the table contains the same data twice).
|
|
echo
|
|
$CLICKHOUSE_CLIENT --query "INSERT INTO squares_protobuf_00825 FORMAT Protobuf SETTINGS format_schema='$SCHEMADIR/00825_protobuf_format_squares:NumberAndSquare'" < "$BINARY_FILE_PATH"
|
|
$CLICKHOUSE_CLIENT --query "SELECT * FROM squares_protobuf_00825"
|
|
|
|
rm "$BINARY_FILE_PATH"
|
|
$CLICKHOUSE_CLIENT --query "DROP TABLE squares_protobuf_00825"
|