Merge pull request #48057 from Avogar/fix-avro-records

Use uniq names for Records in Avro to avoid reusing its schema
This commit is contained in:
Kruglov Pavel 2023-03-28 19:12:41 +02:00 committed by GitHub
commit f3c594a160
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 1 deletions

View File

@ -386,7 +386,9 @@ AvroSerializer::SchemaWithSerializeFn AvroSerializer::createSchemaWithSerializeF
const auto & nested_names = tuple_type.getElementNames();
std::vector<SerializeFn> nested_serializers;
nested_serializers.reserve(nested_types.size());
auto schema = avro::RecordSchema(column_name);
/// We should use unique names for records. Otherwise avro will reuse schema of this record later
/// for all records with the same name.
auto schema = avro::RecordSchema(column_name + "_" + std::to_string(type_name_increment));
for (size_t i = 0; i != nested_types.size(); ++i)
{
auto nested_mapping = createSchemaWithSerializeFn(nested_types[i], type_name_increment, nested_names[i]);

View File

@ -0,0 +1 @@
((1,2)) ((3,4,5))

View File

@ -0,0 +1,8 @@
#!/usr/bin/env bash
# Tags: no-fasttest
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# shellcheck source=../shell_config.sh
. "$CURDIR"/../shell_config.sh
$CLICKHOUSE_LOCAL -q "select tuple(tuple(1, 2))::Tuple(x Tuple(a UInt32, b UInt32)) as c1, tuple(tuple(3, 4, 5))::Tuple(x Tuple(c UInt32, d UInt32, e UInt32)) as c2 format Avro" | $CLICKHOUSE_LOCAL --input-format Avro --structure 'c1 Tuple(x Tuple(a UInt32, b UInt32)), c2 Tuple(x Tuple(c UInt32, d UInt32, e UInt32))' -q "select * from table"