2021-01-11 01:50:30 +00:00
|
|
|
#!/usr/bin/env bash
|
2021-09-12 12:35:27 +00:00
|
|
|
# Tags: no-fasttest
|
2021-01-11 01:50:30 +00:00
|
|
|
|
|
|
|
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
2021-02-19 13:24:57 +00:00
|
|
|
SCHEMADIR=$CURDIR/format_schemas
|
2021-01-11 01:50:30 +00:00
|
|
|
# shellcheck source=../shell_config.sh
|
|
|
|
. "$CURDIR"/../shell_config.sh
|
|
|
|
|
|
|
|
set -eo pipefail
|
|
|
|
|
|
|
|
# Run the client.
|
2024-07-29 20:06:55 +00:00
|
|
|
$CLICKHOUSE_CLIENT <<EOF
|
2021-02-19 13:24:57 +00:00
|
|
|
DROP TABLE IF EXISTS map_protobuf_00825;
|
2021-01-11 01:50:30 +00:00
|
|
|
|
2021-02-19 13:24:57 +00:00
|
|
|
CREATE TABLE map_protobuf_00825
|
2021-01-11 01:50:30 +00:00
|
|
|
(
|
|
|
|
a Map(String, UInt32)
|
|
|
|
) ENGINE = MergeTree ORDER BY tuple();
|
|
|
|
|
2021-02-19 13:24:57 +00:00
|
|
|
INSERT INTO map_protobuf_00825 VALUES ({'x':5, 'y':7}), ({'z':11}), ({'temp':0}), ({'':0});
|
2021-01-11 01:50:30 +00:00
|
|
|
|
2021-02-19 13:24:57 +00:00
|
|
|
SELECT * FROM map_protobuf_00825;
|
2021-01-11 01:50:30 +00:00
|
|
|
EOF
|
|
|
|
|
|
|
|
BINARY_FILE_PATH=$(mktemp "$CURDIR/00825_protobuf_format_map.XXXXXX.binary")
|
2021-02-19 13:24:57 +00:00
|
|
|
$CLICKHOUSE_CLIENT --query "SELECT * FROM map_protobuf_00825 FORMAT Protobuf SETTINGS format_schema = '$SCHEMADIR/00825_protobuf_format_map:Message'" > "$BINARY_FILE_PATH"
|
2021-01-11 01:50:30 +00:00
|
|
|
|
|
|
|
# Check the output in the protobuf format
|
|
|
|
echo
|
|
|
|
echo "Binary representation:"
|
|
|
|
hexdump -C $BINARY_FILE_PATH
|
|
|
|
|
|
|
|
# Check the input in the protobuf format (now the table contains the same data twice).
|
|
|
|
echo
|
2022-04-03 07:52:44 +00:00
|
|
|
$CLICKHOUSE_CLIENT --query "INSERT INTO map_protobuf_00825 SETTINGS format_schema='$SCHEMADIR/00825_protobuf_format_map:Message' FORMAT Protobuf" < "$BINARY_FILE_PATH"
|
2021-02-19 13:24:57 +00:00
|
|
|
$CLICKHOUSE_CLIENT --query "SELECT * FROM map_protobuf_00825"
|
2021-01-11 01:50:30 +00:00
|
|
|
|
|
|
|
rm "$BINARY_FILE_PATH"
|
2021-02-19 13:24:57 +00:00
|
|
|
$CLICKHOUSE_CLIENT --query "DROP TABLE map_protobuf_00825"
|