mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-04 21:42:39 +00:00
c5ffbc688e
Parsing SETTINGS after FORMAT, that has been introduced in [1], can interpret SETTING as some values, which is misleading. [1]: https://github.com/ClickHouse/ClickHouse/pull/4174/files#diff-ba7bd0657630b1cd94cf6ed364bd857338096f49f66dc82918438d6745753775R106 Note, that we are touching only INSERT queries, not SELECT, since this is a backward incompatible change, and in case of modifying SELECT it can break too much. Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com> Fixes: #35100 Fixes: #20343
42 lines
1.3 KiB
Bash
Executable File
42 lines
1.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Tags: no-fasttest
|
|
|
|
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
|
|
SET allow_experimental_map_type = 1;
|
|
|
|
DROP TABLE IF EXISTS map_protobuf_00825;
|
|
|
|
CREATE TABLE map_protobuf_00825
|
|
(
|
|
a Map(String, UInt32)
|
|
) ENGINE = MergeTree ORDER BY tuple();
|
|
|
|
INSERT INTO map_protobuf_00825 VALUES ({'x':5, 'y':7}), ({'z':11}), ({'temp':0}), ({'':0});
|
|
|
|
SELECT * FROM map_protobuf_00825;
|
|
EOF
|
|
|
|
BINARY_FILE_PATH=$(mktemp "$CURDIR/00825_protobuf_format_map.XXXXXX.binary")
|
|
$CLICKHOUSE_CLIENT --query "SELECT * FROM map_protobuf_00825 FORMAT Protobuf SETTINGS format_schema = '$SCHEMADIR/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_protobuf_00825 SETTINGS format_schema='$SCHEMADIR/00825_protobuf_format_map:Message' FORMAT Protobuf" < "$BINARY_FILE_PATH"
|
|
$CLICKHOUSE_CLIENT --query "SELECT * FROM map_protobuf_00825"
|
|
|
|
rm "$BINARY_FILE_PATH"
|
|
$CLICKHOUSE_CLIENT --query "DROP TABLE map_protobuf_00825"
|