mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 00:52:02 +00:00
18e036d19b
Improved matching enum data types to protobuf enum type. Fixed serialization of the Map data type. Omitted values are now set by default.
41 lines
1.2 KiB
Bash
Executable File
41 lines
1.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# https://github.com/ClickHouse/ClickHouse/issues/6497
|
|
|
|
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|
# shellcheck source=../shell_config.sh
|
|
. "$CURDIR"/../shell_config.sh
|
|
|
|
set -eo pipefail
|
|
|
|
# Run the client.
|
|
$CLICKHOUSE_CLIENT --multiquery <<'EOF'
|
|
SET allow_experimental_map_type = 1;
|
|
|
|
DROP TABLE IF EXISTS map_00825;
|
|
|
|
CREATE TABLE map_00825
|
|
(
|
|
a Map(String, UInt32)
|
|
) ENGINE = MergeTree ORDER BY tuple();
|
|
|
|
INSERT INTO map_00825 VALUES ({'x':5, 'y':7}), ({'z':11}), ({'temp':0}), ({'':0});
|
|
|
|
SELECT * FROM map_00825;
|
|
EOF
|
|
|
|
BINARY_FILE_PATH=$(mktemp "$CURDIR/00825_protobuf_format_map.XXXXXX.binary")
|
|
$CLICKHOUSE_CLIENT --query "SELECT * FROM map_00825 FORMAT Protobuf SETTINGS format_schema = '$CURDIR/00825_protobuf_format_map:Message'" > "$BINARY_FILE_PATH"
|
|
|
|
# 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
|
|
$CLICKHOUSE_CLIENT --query "INSERT INTO map_00825 FORMAT Protobuf SETTINGS format_schema='$CURDIR/00825_protobuf_format_map:Message'" < "$BINARY_FILE_PATH"
|
|
$CLICKHOUSE_CLIENT --query "SELECT * FROM map_00825"
|
|
|
|
rm "$BINARY_FILE_PATH"
|