2019-01-23 19:43:23 +00:00
#!/usr/bin/env bash
# To generate reference file for this test use the following commands:
# ninja ProtobufDelimitedMessagesSerializer
2019-02-19 19:53:32 +00:00
# build/utils/test-data-generator/ProtobufDelimitedMessagesSerializer
2019-01-23 19:43:23 +00:00
CURDIR = $( cd " $( dirname " ${ BASH_SOURCE [0] } " ) " && pwd )
2020-08-01 00:51:12 +00:00
. " $CURDIR " /../shell_config.sh
2019-01-23 19:43:23 +00:00
set -e -o pipefail
# Run the client.
2020-09-25 16:17:57 +00:00
$CLICKHOUSE_CLIENT -mnT <<EOF
2019-07-23 13:51:22 +00:00
DROP TABLE IF EXISTS out_persons_00825;
2019-07-23 13:34:05 +00:00
DROP TABLE IF EXISTS out_squares_00825;
2019-07-23 13:51:22 +00:00
CREATE TABLE out_persons_00825 ( uuid UUID,
name String,
surname String,
gender Enum8( 'male' = 1, 'female' = 0) ,
birthDate Date,
2020-10-14 13:32:33 +00:00
photo Nullable( String) ,
2019-07-23 13:51:22 +00:00
phoneNumber Nullable( FixedString( 13) ) ,
isOnline UInt8,
visitTime Nullable( DateTime) ,
age UInt8,
zodiacSign Enum16( 'aries' = 321, 'taurus' = 420, 'gemini' = 521, 'cancer' = 621, 'leo' = 723, 'virgo' = 823,
'libra' = 923, 'scorpius' = 1023, 'sagittarius' = 1122, 'capricorn' = 1222, 'aquarius' = 120,
'pisces' = 219) ,
songs Array( String) ,
color Array( UInt8) ,
hometown LowCardinality( String) ,
location Array( Decimal32( 6) ) ,
pi Nullable( Float64) ,
lotteryWin Nullable( Decimal64( 2) ) ,
someRatio Float32,
temperature Decimal32( 1) ,
randomBigNumber Int64,
measureUnits Nested( unit String, coef Float32) ,
nestiness_a_b_c_d Nullable( UInt32) ,
\` nestiness_a_B.c_E\` Array( UInt32)
) ENGINE = MergeTree ORDER BY tuple( ) ;
2019-07-23 13:34:05 +00:00
CREATE TABLE out_squares_00825 ( number UInt32, square UInt64) ENGINE = MergeTree ORDER BY tuple( ) ;
2019-07-23 13:51:22 +00:00
INSERT INTO out_persons_00825 VALUES ( toUUID( 'a7522158-3d41-4b77-ad69-6c598ee55c49' ) , 'Ivan' , 'Petrov' , 'male' , toDate( '1980-12-29' ) , 'png' , '+74951234567' , 1, toDateTime( '2019-01-05 18:45:00' ) , 38, 'capricorn' , [ 'Yesterday' , 'Flowers' ] , [ 255, 0, 0] , 'Moscow' , [ 55.753215, 37.622504] , 3.14, 214.10, 0.1, 5.8, 17060000000, [ 'meter' , 'centimeter' , 'kilometer' ] , [ 1, 0.01, 1000] , 500, [ 501, 502] ) ;
INSERT INTO out_persons_00825 VALUES ( toUUID( 'c694ad8a-f714-4ea3-907d-fd54fb25d9b5' ) , 'Natalia' , 'Sokolova' , 'female' , toDate( '1992-03-08' ) , 'jpg' , NULL, 0, NULL, 26, 'pisces' , [ ] , [ 100, 200, 50] , 'Plymouth' , [ 50.403724, -4.142123] , 3.14159, NULL, 0.007, 5.4, -20000000000000, [ ] , [ ] , NULL, [ ] ) ;
INSERT INTO out_persons_00825 VALUES ( toUUID( 'a7da1aa6-f425-4789-8947-b034786ed374' ) , 'Vasily' , 'Sidorov' , 'male' , toDate( '1995-07-28' ) , 'bmp' , '+442012345678' , 1, toDateTime( '2018-12-30 00:00:00' ) , 23, 'leo' , [ 'Sunny' ] , [ 250, 244, 10] , 'Murmansk' , [ 68.970682, 33.074981] , 3.14159265358979, 100000000000, 800, -3.2, 154400000, [ 'pound' ] , [ 16] , 503, [ ] ) ;
2019-07-23 13:34:05 +00:00
INSERT INTO out_squares_00825 VALUES ( 2, 4) , ( 0, 0) , ( 3, 9) ;
2019-07-23 13:51:22 +00:00
SELECT * FROM out_persons_00825 ORDER BY name FORMAT Protobuf SETTINGS format_schema = '$CURDIR/00825_protobuf_format:Person' ;
2019-01-23 19:43:23 +00:00
SELECT 'ALTERNATIVE->' ;
2019-07-23 13:51:22 +00:00
SELECT * FROM out_persons_00825 ORDER BY name FORMAT Protobuf SETTINGS format_schema = '$CURDIR/00825_protobuf_format:AltPerson' ;
2019-01-23 19:43:23 +00:00
SELECT 'STRINGS->' ;
2019-07-23 13:51:22 +00:00
SELECT * FROM out_persons_00825 ORDER BY name FORMAT Protobuf SETTINGS format_schema = '$CURDIR/00825_protobuf_format:StrPerson' ;
2019-01-23 19:43:23 +00:00
SELECT 'SYNTAX2->' ;
2019-07-23 13:51:22 +00:00
SELECT * FROM out_persons_00825 ORDER BY name FORMAT Protobuf SETTINGS format_schema = '$CURDIR/00825_protobuf_format_syntax2:Syntax2Person' ;
2019-07-23 13:34:05 +00:00
SELECT 'SQUARES->' ;
SELECT * FROM out_squares_00825 ORDER BY number FORMAT Protobuf SETTINGS format_schema = '$CURDIR/00825_protobuf_format:NumberAndSquare' ;
2019-04-18 18:48:04 +00:00
2020-09-25 16:17:57 +00:00
SELECT '\n\n** ProtobufSingle **\n\n' ;
SELECT * FROM out_persons_00825 ORDER BY name LIMIT 1 FORMAT ProtobufSingle SETTINGS format_schema = '$CURDIR/00825_protobuf_format:Person' ;
SELECT 'ALTERNATIVE->' ;
SELECT * FROM out_persons_00825 ORDER BY name LIMIT 1 FORMAT ProtobufSingle SETTINGS format_schema = '$CURDIR/00825_protobuf_format:AltPerson' ;
SELECT 'STRINGS->' ;
SELECT * FROM out_persons_00825 ORDER BY name LIMIT 1 FORMAT ProtobufSingle SETTINGS format_schema = '$CURDIR/00825_protobuf_format:StrPerson' ;
SELECT 'SYNTAX2->' ;
SELECT * FROM out_persons_00825 ORDER BY name LIMIT 1 FORMAT ProtobufSingle SETTINGS format_schema = '$CURDIR/00825_protobuf_format_syntax2:Syntax2Person' ;
SELECT 'SQUARES->' ;
SELECT * FROM out_squares_00825 ORDER BY number LIMIT 1 FORMAT ProtobufSingle SETTINGS format_schema = '$CURDIR/00825_protobuf_format:NumberAndSquare' ;
2020-10-14 13:30:15 +00:00
-- Code: 546, e.displayText( ) = DB::Exception: The ProtobufSingle format can't be used to write multiple rows because this format doesn' t have any row delimiter.
SELECT * FROM out_persons_00825 ORDER BY name FORMAT ProtobufSingle SETTINGS format_schema = '$CURDIR/00825_protobuf_format:Person' ; -- { clientError 546 }
2020-09-25 16:17:57 +00:00
2019-07-23 13:51:22 +00:00
DROP TABLE IF EXISTS out_persons_00825;
2019-07-23 13:34:05 +00:00
DROP TABLE IF EXISTS out_squares_00825;
2019-01-23 19:43:23 +00:00
EOF